help with signals

Guy Harris guy at auspex.UUCP
Sat Feb 18 19:00:17 AEST 1989


>    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.



More information about the Comp.unix.questions mailing list