wait3 emulation in SYSTEMV ?? - (nf)
jh at pcsbst
jh at pcsbst
Mon Jan 18 19:20:00 AEST 1988
The newer versions of System V provide the possibilty to check
the existence of a process by sending a signal 0 to the process
in question and checking for an error return. This would allow
you to write a write a pseudo wait3() function for terminated
processes:
int wait3_for_sysV (testpid, status, options, rusage)
int testpid;
union wait * status;
int options;
struct rusage * rusage; /* not used */
{
....
if (options & WNOHANG) {
if (kill (testpid, 0) == -1) {
if (errno != EPERM)
return (wait (status));
else
return (BUG);
} else {
return (STILLRUNNING);
}
} else {
return (wait (status));
}
}
This is only an example. Check for possible different error
returns of the kill() system call. For a better implementation
you should poll all pids in question.
I hope this did help you.
Johannes Heuft
unido!pcsbst!jh
More information about the Comp.unix.questions
mailing list