24 #include <sys/types.h>
38 typedef void (*SigHdlr)(int);
66 printf(
"pressed CTRL-C %d times. forcing termination.\n",
ninterrupts);
71 printf(
"pressed CTRL-C %d times (5 times for forcing termination)\n",
ninterrupts);
80 assert(interrupt !=
NULL);
83 (*interrupt)->nuses = 0;
93 assert(interrupt !=
NULL);
103 assert(interrupt !=
NULL);
104 assert(interrupt->
nuses >= 0);
106 if( interrupt->
nuses == 0 )
111 struct sigaction newaction;
115 newaction.sa_flags = 0;
116 (void)sigemptyset(&newaction.sa_mask);
119 (void)sigaction(SIGINT, &newaction, &interrupt->
oldsigaction);
132 assert(interrupt !=
NULL);
133 assert(interrupt->
nuses >= 1);
136 if( interrupt->
nuses == 0 )
139 (void)signal(SIGINT, interrupt->oldsighdlr);