28 #include <sys/types.h>
37 #include <lib$routines.h>
103 m_pid = (long) OpenProcess(PROCESS_ALL_ACCESS,TRUE,
m_dwProcessId);
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;
209 STARTUPINFO si = {
sizeof(si)};
210 PROCESS_INFORMATION pi;
211 DWORD dwCreationFlags;
214 dwCreationFlags = CREATE_NO_WINDOW;
215 if (
prio == 0) dwCreationFlags |= IDLE_PRIORITY_CLASS;
216 else if(
prio == 1) dwCreationFlags |= NORMAL_PRIORITY_CLASS;
217 else if(
prio == 2) dwCreationFlags |= HIGH_PRIORITY_CLASS;
218 else if(
prio == 3) dwCreationFlags |= REALTIME_PRIORITY_CLASS;
221 , FALSE, dwCreationFlags
224 m_pid = (int) pi.hProcess;
226 CloseHandle(pi.hThread);
233 if(
m_pid == -1)
return -1;
234 if(
m_pid == 0)
return -1;
249 TerminateProcess((HANDLE)
m_pid, 0);
250 WaitForSingleObject((HANDLE) m_pid, 60000);
251 CloseHandle((HANDLE) m_pid);
278 if(
m_pid == -1)
return -1;
279 if(
m_pid == 0)
return -1;
291 TerminateProcess((HANDLE)
m_pid, 0);
292 WaitForSingleObject((HANDLE) m_pid, 60000);
293 CloseHandle((HANDLE) m_pid);
305 if(
m_pid == -1)
return 0;
308 ret = lib$getjpi(&code,&mypid,0,0,0,0);
309 if(ret != SS$_NORMAL)
314 if(mypid ==
m_pid)
return 1;
321 if(
m_pid == -1)
return 0;
322 ret = waitpid(
m_pid, &status, WNOHANG);
324 if(ret == 0)
return 1;
331 if(
m_pid == -1)
return 0;
332 if(GetExitCodeProcess((HANDLE)
m_pid, (
unsigned long *) &status) != 0)
334 if(status == STILL_ACTIVE)
return 1;
351 while(item->
next != NULL) item = item->
next;
360 m_input =
new char [strlen(input)+1];
367 m_output =
new char [strlen(output)+1];
374 m_error =
new char [strlen(error)+1];
383 if(pri > 15) pri = 15;