--- ray/src/common/unix_process.c 2003/06/26 00:58:09 3.1 +++ ray/src/common/unix_process.c 2004/09/17 21:43:49 3.5 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: unix_process.c,v 3.1 2003/06/26 00:58:09 schorsch Exp $"; +static const char RCSid[] = "$Id: unix_process.c,v 3.5 2004/09/17 21:43:49 greg Exp $"; #endif /* * Routines to communicate with separate process via dual pipes @@ -10,8 +10,10 @@ static const char RCSid[] = "$Id: unix_process.c,v 3.1 #include "copyright.h" +#include +#include + #include "rtprocess.h" -#include "vfork.h" int @@ -31,7 +33,7 @@ char *av[] return(0); if (pipe(p0) < 0 || pipe(p1) < 0) return(-1); - if ((pd->pid = vfork()) == 0) { /* if child */ + if ((pd->pid = fork()) == 0) { /* if child */ close(p0[1]); close(p1[0]); if (p0[0] != 0) { /* connect p0 to stdin */ @@ -65,12 +67,13 @@ SUBPROC *pd { int pid, status; + if (!pd->running) + return(0); close(pd->r); close(pd->w); pd->running = 0; - while ((pid = wait(&status)) != -1) - if (pid == pd->pid) - return(status>>8 & 0xff); + if (waitpid(pd->pid, &status, 0) == pd->pid) + return(status>>8 & 0xff); return(-1); /* ? unknown status */ }