Path: utzoo!attcan!uunet!jarthur!bridge2!mips!zaphod.mps.ohio-state.edu!think!snorkelwacker!bloom-beacon!eru!luth!sunic!sics.se!uplog.se!uplog.uplog.se!thomas From: thomas@uplog.se (Thomas Tornblom) Newsgroups: comp.unix.questions Subject: Re: Can a parent process determine its child's status ? Message-ID: Date: 22 Feb 90 11:44:43 GMT References: <5090.25e135aa@mva.cs.liv.ac.uk> Sender: thomas@uplog.se (Thomas Tornblom) Organization: TeleLOGIC Uppsala AB Lines: 39 In-Reply-To: adh@mva.cs.liv.ac.uk's message of 20 Feb 90 12:18:50 GMT In article <5090.25e135aa@mva.cs.liv.ac.uk> adh@mva.cs.liv.ac.uk writes: Does anyone know how a parent process can determine the status of one of its children if it *hasn't* executed a wait ? It could arrange to catch a SIGCLD signal, but if the parent had several children it wouldn't know which one had sent it the SIGCLD ... would it ? Yes it would. Arrange to catch SIGCLD and do a wait in the catcher: main() { . . signal(SIGCLD, reaper); . . } reaper() { int pid; int status; pid = wait(&status); /* pid is now the pid of the child that has died/changed status */ signal(SIGCLD, reaper); /* have to re-initialize in sysV */ } Hope this helps. Thomas -- Real life: Thomas Tornblom Email: thomas@uplog.se Snail mail: TeleLOGIC Uppsala AB Phone: +46 18 189406 Box 1218 Fax: +46 18 132039 S - 751 42 Uppsala, Sweden