help determining child process status

Kory Hamzeh kory at avatar.UUCP
Fri Jun 9 10:14:31 AEST 1989


In article <1854 at leah.Albany.Edu>, msb62 at leah.Albany.Edu (Mitch Baltuch) writes:
> I am running SCO Xenix v2.3 on a Zenith Z386, using their v2.3 development
> toolkit.  My problem is that I have a parent task which forks a number
> of tasks.  Some of these tasks spawn other tasks based on asynchronous
> events, so that the number and duration of these tasks cannot be determined.
> I am looking for a way that a task can tell when all its children have
> terminated.  This is complicated by the fact that one or two processes may
> not terminate by themselves and cannot be terminated until all other
> processes have exited. I have not been able to find a convenient way to
> accomplish this.  Any suggestions?

If you know the pids of the sub-tasks, you can do a kill(pid, 0). Under
Xenix, kill(pid, 0) returns 0 (zero) if the task is still running or 
-1 if the task is terminated. I have tried this under Xenix and it works.
However, I know that it is not very portable to other flavors of Unix.

Hope this helps.

--kory



-- 
-------------------------------------------------------------------------------
Kory Hamzeh			    UUCP:     ..!uunet!psivax!quad1!avatar!kory
				    INTERNET: avatar!kory at quad.com



More information about the Comp.unix.questions mailing list