wolfe@winston.UUCP (Peter Wolfe) (01/24/86)
I am having a problem with 4.2BSD signals and would like some light shed on
my problem.
I am using the ITIMER_VIRTUAL interval timer to generate periodic (6666
micro second interval) clock interrupts for a OS I am writing. The signal
SIGVTALRM is delivered to a catcher function which calls a handler etc.
I also turn off interrupts (i.e. block signals) during critical sections
using oldmask = sigblock(sigs) and sigsetmask(oldmask).
The problem is that I get SIGVTALRM signals delivered when SIGVTALRM is
(well at least it should be) blocked from delivery. This obviously
causes problems and the OS (the one I am writing) crashes. I look
(using dbx) at the sc_mask field of the sig_context structure passed to
the signal catcher and lo and behold SIGVTALRM is set as being
ignored!!! What gives??? Am I missing something??? Has anyone else
had this problem??? The problem can not be reliably repeated but if I
run the program I get about one crash in every seven runs.
Helpppppppppppp .....
Drowning in Signals and handlers.
--
Peter Wolfe
New Media Technologies
..decvax!microsoft!ubc-vision!winston!wolfe
..ihnp4!alberta!ubc-vision!winston!wolfewolfe@winston.UUCP (Peter Wolfe) (01/24/86)
Well, is my face slightly red or what!!! I discovered what the problem
was.
The man page for sig block says:
Signal i is blocked if the i-th bit in mask is a 1.
well, what they really want you to do is:
to block signal X set the (X-1) bit in the mask
E.g.
sigblock(1 << (SIGVTALRM - 1));
will block SIGVTALRM.
Of course once I had posted the article and described the problem to a
colleague the solution seemed obvious (I also looked at the kernel code and
noticed the (sig-1) used).
So there you have it. Read the manual and read between the manual if
system == UNIX.
--
Peter Wolfe
New Media Technologies
..decvax!microsoft!ubc-vision!winston!wolfe
..ihnp4!alberta!ubc-vision!winston!wolfechris@umcp-cs.UUCP (Chris Torek) (01/28/86)
> The man page for sig block says: > Signal i is blocked if the i-th bit in mask is a 1. > well, what they really want you to do is: ... sigblock(1 << (signun - 1)) There is no contradiction here. The first bit is bit 0; the 32nd bit is bit 31; and the i'th bit is bit i-1. I agree that the manual should be much more explicit. In 4.3, <signal.h> defines a macro called `sigmask' which should be used when creating signal masks: omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); ... (void) sigsetmask(omask); Note that there really should be a `signal mask' type, too; `int' enforces a maximum of 16 signals on some machines. Having a separate type name would allow more than 32 signals, too. Maybe in 4.4.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu