]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - warp/sig.c
a4cb1735e4d675ec8e766a2a640b0e967cf329fc
1 /* $Header: /cvsroot/src/games/warp/sig.c,v 1.1 2020/11/09 23:37:05 kamil Exp $ */
4 /* Revision 1.1 2020/11/09 23:37:05 kamil
5 /* Add Warp Kit, Version 7.0 by Larry Wall
7 /* Warp is a real-time space war game that doesn't get boring very quickly.
8 /* Read warp.doc and the manual page for more information.
10 /* games/warp originally distributed with 4.3BSD-Reno, is back to the BSD
11 /* world via NetBSD. Its remnants were still mentioned in games/Makefile.
13 /* Larry Wall, the original author and the copyright holder, generously
14 /* donated the game and copyright to The NetBSD Foundation, Inc.
16 /* Import the game sources as-is from 4.3BSD-Reno, with the cession
17 /* of the copyright and license to BSD-2-clause NetBSD-style.
19 /* Signed-off-by: Larry Wall <larry@wall.org>
20 /* Signed-off-by: Kamil Rytarowski <kamil@netbsd.org>
22 * Revision 7.0.1.1a 87/07/03 01:47:11 games
23 * Changed sigsetmask to use sigmask instead of calculating it (incorrectly)
26 * Revision 7.0.1.1 86/12/12 17:02:44 lwall
27 * Baseline for net release.
29 * Revision 7.0 86/10/08 15:13:24 lwall
30 * Split into separate files. Added amoebas and pirates.
49 sigignore(SIGINT
); /* for inquiry of existence via kill call */
54 sigset(SIGHUP
, sig_catcher
);
56 sigset(SIGQUIT
, sig_catcher
);
57 sigset(SIGILL
, sig_catcher
);
58 sigset(SIGFPE
, sig_catcher
);
59 sigset(SIGBUS
, sig_catcher
);
60 sigset(SIGSEGV
, sig_catcher
);
61 sigset(SIGSYS
, sig_catcher
);
62 sigset(SIGTERM
, sig_catcher
);
65 sigset(SIGXCPU
, sig_catcher
);
68 sigset(SIGCONT
, cont_catcher
);
71 sigset(SIGTSTP
, stop_catcher
);
72 sigset(SIGSTOP
, stop_catcher
);
82 sigset(SIGCONT
,cont_catcher
);
102 char *shell
= getenv("SHELL");
107 execl(shell
,shell
,0);
114 void /* very much void */
122 sigset(SIGILL
,SIG_DFL
);
128 /* come here on signal other than interrupt, stop, or cont */
134 static char *signame
[] = {
177 printf("\r\nSIG%s--game not saved in debug\r\n",signame
[signo
]);
188 (void) sigset(SIGILL
,SIG_DFL
);
189 if (signo
== SIGHUP
&& (timer
< 10 || didkill
))
191 if (signo
== SIGQUIT
) { /* can't let them bomb out without penalty */
194 else if (smarts
< 35)
198 totalscore
-= possiblescore
/ 2;
201 if (signo
!= SIGHUP
&& signo
!= SIGQUIT
)
204 printf("\r\nCaught %s%s--%s\r\n",
205 signo
? "a SIG" : "an internal error", signame
[signo
],
206 experimenting
? "game saved" : "bye bye");
210 printf("\r\nSignal %d--bye bye\r\n",signo
);
218 finalize(1); /* and blow up */
222 /* come here on stop signal */
228 resetty(); /* this is the point of all this */
231 write(2,"stop_catcher\r\n",13);
233 sigset(SIGTSTP
,SIG_DFL
); /* enable stop */
235 sigsetmask(sigblock(0L) & ~sigmask(SIGTSTP
));
237 kill(0,SIGTSTP
); /* and do the stop */
240 sigset(SIGTSTP
,stop_catcher
); /* unenable the stop */