Hi,
I'm porting an ancient C program to Linux and I have 2 versions of this function, one for BSD and one for SYS V.
I'm not sure if either is appropriate for Linux, but the only real difference is the call to wait() (the SYS V version uses 'union wait status' instead of 'int status'). Here's the BSD version:
Code:
int
spawnvp( mode, path, argv )
int mode;
char *path;
char *argv[];
{
int pid;
int status;
fflush( stdout );
fflush( stderr );
signal(SIGCHLD, SIG_DFL);
switch ( pid = fork() ) {
case -1: /* error */
return -1;
case 0: /* child */
exit( execvp( path, argv ) );
default: /* parent */
while ( wait( &status ) != pid )
;
return status ? -1 : 0;
}
}
I can't see any reason why this wouldn't work fine on Linux, but then again, I never use those fork(), execvp(), signal()... functions.
Will this work as expected (which of course is undocumented, so I can only guess)?