Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!hubcap!ncrcae!ncrlnk!uunet!auspex!guy From: guy@auspex.UUCP (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: help with signals Keywords: signals, wait, signal number Message-ID: <1039@auspex.UUCP> Date: 18 Feb 89 09:00:17 GMT References: <8517@dasys1.UUCP> <201@carroll1.UUCP> <2718@nunki.usc.edu> Reply-To: guy@auspex.UUCP (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 44 > Alternately, can I find out what signal was delivered, without declaring > those signal_no,code,scp,addr arguments? Not without declaring "signal_no", but you can blow off the other three arguments. You can just do sig_catch(signal_no) int signal_no; which all sufficiently modern UNIX implementations should support. The fact that the manual page mentions other arguments merely indicates that the implementors have made it possible for handlers to be declared with the extra arguments and that, for some signals in some circumstances, those arguments will have meaningful (and possibly useful) values, not that it won't work if you declare the function with only one argument. (If they couldn't make it work regardless of whether you declared it with only one "int" argument or all the arguments, they'd better have provided a different mechanism for giving you the other arguments, since they'll break one hell of a lot of code otherwise. Fortunately, from the appearance of the "addr" argument, you're probably working on a Sun - or a Solbourne :-) - in which case I know it works either way.) (BTW, note that the SVID, issue 2, actually allows for extra arguments; on page 123 in SIGNAL(BA_OS), it says: ...Additional arguments may be passed to the signal-catching function for hardware-generated signals. ) >How can I reset the signal mask that wait() reads, so that wait() >ignores the exit signal of the first 2 child processes? You can't. "wait" *doesn't* read the signal mask. >Actually, I already do have a fix for this. I do: > while ( (pid=wait(&status)) != cpid1 && pid != -1 ) > ; > while ( (pid=wait(&status)) != cpid2 && pid != -1 ) > ; >which works as intended. That is the correct way to do what you want.