Use "sigset" for correct "signal" semantics

Use "sigset" for correct "signal" semantics

Post by Marc D. Rossn » Fri, 15 Jul 1994 03:08:54

It's amazing that there is so much misunderstanding about this.

If you want the old SunOS4.1 semantics of "signal", use "sigset" in
your Solaris 2.x programs.

i.e. sigset(SIGTERM, my_catch_it_fn);

This works just as "signal" used to in SunOX4.1.  Signal will be caught
"reliably", i.e. new instances will be held until the current when is
completely handled, i.e. until the handler function finishes.  At that
point, the hadnler will be automatically reinstalled.

If you are porting a SunOS4.1 program with 80,000 "signal" calls, just
#define signal(a, b) sigset(a, b)

Do NOT use "signal" in Solaris 2.x.  Even if you reinstall the handler within
the hadnler itself, it is possible to receive two signals in such quick
succession that you're program gets blown away before your handler is

Phew!  By the way, this has been in SysV since 1987-ish.  Solaris 2.x is SysV.

NOW, if you want "fancier", signal handling, you can use the sigaction /
sigsetmask stuff instead.  Here you can automatically hold a whole set
of signals immediately upon receiving a single one.

Marc Rossner
Taos Mountain Software