]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/sig.c
1 /* Header: /usr/src/games/warp/RCS/sig.c,v 1.1 87/07/03 01:47:11 games Exp */
4 * Revision 7.0.1.1a 87/07/03 01:47:11 games
5 * Changed sigsetmask to use sigmask instead of calculating it (incorrectly)
8 * Revision 7.0.1.1 86/12/12 17:02:44 lwall
9 * Baseline for net release.
11 * Revision 7.0 86/10/08 15:13:24 lwall
12 * Split into separate files. Added amoebas and pirates.
28 sigignore(SIGINT
); /* for inquiry of existence via kill call */
33 sigset(SIGHUP
, sig_catcher
);
35 sigset(SIGQUIT
, sig_catcher
);
36 sigset(SIGILL
, sig_catcher
);
37 sigset(SIGFPE
, sig_catcher
);
39 sigset(SIGBUS
, sig_catcher
);
40 sigset(SIGSEGV
, sig_catcher
);
42 sigset(SIGSYS
, sig_catcher
);
43 sigset(SIGTERM
, sig_catcher
);
46 sigset(SIGXCPU
, sig_catcher
);
49 sigset(SIGCONT
, cont_catcher
);
52 sigset(SIGTSTP
, stop_catcher
);
53 sigset(SIGSTOP
, stop_catcher
);
62 sigset(SIGCONT
,cont_catcher
);
82 char *shell
= getenv("SHELL");
94 void /* very much void */
101 sigset(SIGILL
,SIG_DFL
);
107 /* come here on signal other than interrupt, stop, or cont */
110 sig_catcher(int signo
)
113 static const char *signame
[] = {
156 printf("\r\nSIG%s--game not saved in debug\r\n",signame
[signo
]);
167 (void) sigset(SIGILL
,SIG_DFL
);
168 if (signo
== SIGHUP
&& (timer
< 10 || didkill
))
170 if (signo
== SIGQUIT
) { /* can't let them bomb out without penalty */
173 else if (smarts
< 35)
177 totalscore
-= possiblescore
/ 2;
180 if (signo
!= SIGHUP
&& signo
!= SIGQUIT
) {
183 printf("\r\nCaught %s%s--%s\r\n",
184 signo
? "a SIG" : "an internal error", signame
[signo
],
185 experimenting
? "game saved" : "bye bye");
189 printf("\r\nsignal %d--bye bye\r\n",signo
);
198 finalize(1); /* and blow up */
202 /* come here on stop signal */
205 stop_catcher(int sig
)
208 resetty(); /* this is the point of all this */
211 write(2,"stop_catcher\r\n",13);
213 sigset(SIGTSTP
,SIG_DFL
); /* enable stop */
215 sigsetmask(sigblock(0L) & ~sigmask(SIGTSTP
));
217 kill(0,SIGTSTP
); /* and do the stop */
220 sigset(SIGTSTP
,stop_catcher
); /* unenable the stop */