Path: utzoo!utgpu!watserv1!watmath!att!cbnews!jrl From: jrl@cbnews.att.com (john.lupien) Newsgroups: comp.unix.wizards Subject: Re: How can a parent find out if one of its children is still alive Message-ID: <1990Jun5.201351.27357@cbnews.att.com> Date: 5 Jun 90 20:13:51 GMT References: <30408@cup.portal.com> <6334@ozdaltx.UUCP> Distribution: na Organization: AT&T Bell Laboratories Lines: 29 In article <6334@ozdaltx.UUCP> toma@ozdaltx.UUCP (Tom Armistead) writes: >In article <30408@cup.portal.com>, DeadHead@cup.portal.com (Bruce M Ong) writes: >> I am sure there is a very easy way to do this, but I just havent >> figured this one out: >> How can a parent find out if one of its children is still alive >> or not without >If you have the process id of the child you can use kill(2) to find out if >it is still there. >i.e.: if( kill( child_pid, 0 ) == -1 ) > puts( "The child is dead" ); >Signal 0 is called the NULL signal and is used to validate a process id, no >signal is actually sent to the destination process. This is nice in that, with a small change, you can use it to find out if processes belonging to other uid's are alive, provided you know their pid. If kill(child_pid, 0) returns other than -1, the process exists and you have permission to kill (007?) If it returns -1 and an errno of ESRCH, the pid does not exist, otherwise you typically get errno of EPERM. -- -John Lupien mvuxr!jrl jrl@mvuxr.att.com