I have the following two programs which are (roughly) equivalent:
--- #1 -------
#include <stdio.h>
#include <signal.h>
main() {
void sig();
signal(SIGINT, sig);
printf("press cnt-c\n");
sleep(10000);
void sig() {Quote:}
printf("cnt-c pressed\n");
---- #2 ----Quote:}
#include <stdio.h>
#include <signal.h>
main() {
void sig();
struct sigaction act;
act.sa_handler = act;
sigemptyset(&act.sa_mask);
sigaction(SIGINT, &act, 0);
printf("press cnt-c\n");
sleep(10000);
void sig() {Quote:}
printf("cnt-c pressed\n");
------------Quote:}
the problem:
if compiled under 4.1.x they each enter the sig() routine everytime
control-c is pressed.
if compiled under sol 2.3 they enter only on the first control-c and
then apparently clear the sig mask and the next control-c pressed
is not caught.
this happens for all signals.. i checked the solaris porting faq and it
didnt indicate anything odd about svr4 clearing its sig masks once the
sig is handled..
what is going wrong?