hulsebos@ehvie0.tq.ine.philips.nl (rob hulsebos) (12/15/89)
When I run this program on my System V.2 or V.3 box, and then send it a SIGTERM signal, the loop in "die()" is executed until the "sleep" terminates. From that moment on, the loop in "main()" is executed. This is not the behaviour I expect: the routine "die()" should *not* exit but continue to execute. Apparently, when the SIGALRM goes off inside "sleep", the kernel executes the signal-handler internal to "sleep", but forgets to return to the original signal-handling routine "die()" it was executing. From this I conclude that signal-handling routines can not be stacked on a V.2 or V.3 system (it works as expected on BSD), probably because of a setjmp/longjmp construction in "sleep". Am I correct, or is there something wrong in V.2/V.3, or is this a bug in my system? #include "signal.h" int die(); int flag = 1; main() { int i; signal(SIGTERM, die ); while(1 ) { sleep(1 ); if (!flag ) write(1, "!flag\n", 6 ); /* should not be printed */ } } die() { flag = 0; while(1 ) write(1, "signal\n", 7 ); } When you've compiled this program, run it in the background and then send it a SIGTERM. A few lines of "signal" will be printed followed be lines with "!flag". From this I conclude that signal-handling routines can not be stacked on a V.2 or V.3 system (it works as expected on BSD), probably because of a setjmp/longjmp construction in "sleep". Am I correct, or is there something wrong in V.2/V.3, or is this a bug in my system? ------------------------------------------------------------------------------- Rob Hulsebos == hulsebos@tq.ine.philips.nl Tel +31-40-785723, Fax +31-40-786114 Philips I&E - Where the future is being made today!
gcardwel@orion.oac.uci.edu (Guy Cardwell) (12/16/89)
In article <608@ehvie0.tq.ine.philips.nl> hulsebos@ehvie0.tq.ine.philips.nl (rob hulsebos) writes: >From this I conclude that signal-handling routines can not be stacked >on a V.2 or V.3 system (it works as expected on BSD), probably because >of a setjmp/longjmp construction in "sleep". Am I correct, or is there >something wrong in V.2/V.3, or is this a bug in my system? One of the major "innovations" in BSD over Sys V was the fact that signals are stacked. Some implementations may support it. (AIX, for example) Guy -- look.... even a test signature.....