From: Rolf K. <lab...@us...> - 2006-10-27 20:52:19
|
Update of /cvsroot/opengtoolkit/pipe/c_source In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10236/c_source Modified Files: pipes.c Log Message: Added command line parsing for Unix Index: pipes.c =================================================================== RCS file: /cvsroot/opengtoolkit/pipe/c_source/pipes.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pipes.c 27 Oct 2006 20:09:58 -0000 1.17 --- pipes.c 27 Oct 2006 20:52:17 -0000 1.18 *************** *** 50,53 **** --- 50,55 ---- MgErr LibAPI PipeWrite(uInt32 fd, uInt32 offset, uInt32 *bytesWritten, LStrHandle data); + MgErr LibAPI KillProcess(uInt32 pid); + #if defined(MSWin) #define STANDARD_IN STD_INPUT_HANDLE *************** *** 72,76 **** static MgErr RedirectStandardIO(int32 type, std_handle *stdIO, pipe_handle *rmpipe, uInt32 *lvpipe); static MgErr RestoreStandardIO(int32 type, std_handle *stdIO, pipe_handle rmpipe, uInt32 *lvpipe, MgErr err); ! static MgErr CreateChildProcess(LPSTR cmdline, pipe_handle stdIn, pipe_handle stdOut, pipe_handle stdErr, uInt32 *pid); --- 74,78 ---- static MgErr RedirectStandardIO(int32 type, std_handle *stdIO, pipe_handle *rmpipe, uInt32 *lvpipe); static MgErr RestoreStandardIO(int32 type, std_handle *stdIO, pipe_handle rmpipe, uInt32 *lvpipe, MgErr err); ! static MgErr CreateChildProcess(LPCSTR cmdline, pipe_handle stdIn, pipe_handle stdOut, pipe_handle stdErr, uInt32 *pid); *************** *** 261,264 **** --- 263,267 ---- CloseHandle(handle); #elif defined(Unix) + kill( pid, SIGKILL ); #else err = mgNotImplementd; *************** *** 534,542 **** CloseHandle(piProcInfo.hThread); #elif defined(Unix) ! int pi; /* parse command line into arguments */ ! ! /* spawn the child process */ --- 537,557 ---- CloseHandle(piProcInfo.hThread); #elif defined(Unix) ! int pi, i = 1; ! char *argv[64]; /* parse command line into arguments */ ! while (*cmdline != '\0' && i < 64) ! { ! /* if not the end of cmdline ..... */ ! while (*cmdline == ' ' || *cmdline == '\t' || ! *cmdline == '\n' || *cmdline == '\r') ! *cmdline++ = '\0'; /* replace white spaces with 0 */ ! *argv++ = cmdline; /* save the argument position */ ! while (*cmdline != '\0' && *cmdline != ' ' && ! *cmdline != '\t' && *cmdline != '\n' && *cmdline != '\r') ! cmdline++; /* skip the argument until ... */ ! i++; ! } ! *argv = '\0'; /* mark the end of argument list */ /* spawn the child process */ *************** *** 546,550 **** { /* This is the child process. Execute the command */ ! execvp(cvs_process->args[0], cvs_process->args); _exit(1); } --- 561,565 ---- { /* This is the child process. Execute the command */ ! execvp(args[0], args); _exit(1); } *************** *** 553,563 **** /* fork failed */ *pid = 0L; ! return dvOpenErr; } else *pid = pi; - #else ! return mgNotImplementd #endif return err; --- 568,577 ---- /* fork failed */ *pid = 0L; ! err = dvOpenErr; } else *pid = pi; #else ! return mgNotImplementd #endif return err; |