28 #include <sys/types.h> 37 #include <lib$routines.h> 116 if(
m_pid == -1)
return 0;
117 if(
m_pid == 0)
return 0;
135 if(str == NULL)
return -1;
136 else return strlen(str);
146 if((
m_pid = ::fork()) == 0)
157 struct dsc$descriptor_s image,prcnam,input,output,error,*inputptr,*outputptr,*errorptr;
160 image.dsc$b_dtype = DSC$K_DTYPE_T;
161 image.dsc$b_class = DSC$K_CLASS_S;
165 prcnam.dsc$b_dtype = DSC$K_DTYPE_T;
166 prcnam.dsc$b_class = DSC$K_CLASS_S;
170 input.dsc$b_dtype = DSC$K_DTYPE_T;
171 input.dsc$b_class = DSC$K_CLASS_S;
175 output.dsc$b_dtype = DSC$K_DTYPE_T;
176 output.dsc$b_class = DSC$K_CLASS_S;
180 error.dsc$b_dtype = DSC$K_DTYPE_T;
181 error.dsc$b_class = DSC$K_CLASS_S;
184 inputptr = outputptr = errorptr = 0;
185 if( input.dsc$w_length > 0) inputptr = &input;
186 if(output.dsc$w_length > 0) outputptr = &output;
187 if( error.dsc$w_length > 0) errorptr = &error;
189 if( inputptr != 0 && inputptr->dsc$a_pointer == NULL) inputptr = 0;
190 if(outputptr != 0 && outputptr->dsc$a_pointer == NULL) outputptr = 0;
191 if( errorptr != 0 && errorptr->dsc$a_pointer == NULL) errorptr = 0;
203 ret = sys$creprc(&
m_pid,&image,inputptr,outputptr,errorptr,0,0,&prcnam,
prio,0,0,0,0,0);
204 if(ret != SS$_NORMAL)
return -1;
211 PROCESS_INFORMATION pi;
212 DWORD dwCreationFlags;
215 dwCreationFlags = CREATE_NO_WINDOW;
216 if (
prio == 0) dwCreationFlags |= IDLE_PRIORITY_CLASS;
217 else if(
prio == 1) dwCreationFlags |= NORMAL_PRIORITY_CLASS;
218 else if(
prio == 2) dwCreationFlags |= HIGH_PRIORITY_CLASS;
219 else if(
prio == 3) dwCreationFlags |= REALTIME_PRIORITY_CLASS;
222 , FALSE, dwCreationFlags
225 m_pid = (int) pi.hProcess;
227 CloseHandle(pi.hThread);
234 if(
m_pid == -1)
return -1;
235 if(
m_pid == 0)
return -1;
250 TerminateProcess((HANDLE)
m_pid, 0);
251 WaitForSingleObject((HANDLE)
m_pid, 60000);
252 CloseHandle((HANDLE)
m_pid);
279 if(
m_pid == -1)
return -1;
280 if(
m_pid == 0)
return -1;
292 TerminateProcess((HANDLE)
m_pid, 0);
293 WaitForSingleObject((HANDLE)
m_pid, 60000);
294 CloseHandle((HANDLE)
m_pid);
306 if(
m_pid == -1)
return 0;
309 ret = lib$getjpi(&code,&mypid,0,0,0,0);
310 if(ret != SS$_NORMAL)
315 if(mypid ==
m_pid)
return 1;
322 if(
m_pid == -1)
return 0;
323 ret = waitpid(
m_pid, &status, WNOHANG);
325 if(ret == 0)
return 1;
332 if(
m_pid == -1)
return 0;
333 if(GetExitCodeProcess((HANDLE)
m_pid, (
unsigned long *) &status) != 0)
335 if(status == STILL_ACTIVE)
return 1;
352 while(item->
next != NULL) item = item->
next;
361 m_input =
new char [strlen(input)+1];
368 m_output =
new char [strlen(output)+1];
375 m_error =
new char [strlen(error)+1];
384 if(pri > 15) pri = 15;
const char * startupCommand()
void setOutput(const char *output)
void setError(const char *error)
void setInput(const char *input)
int rlexec(const char *command)
int rlstrlen(const char *str)
void setPriority(int priority)
const char * processName()
void setStartupCommand(const char *command, const char *process_name)