2 Dedicated treatment of the sigtrp system call, MON 48.
5 /* $Id: m_sigtrp.c,v 2.5 1994/06/24 10:48:02 ceriel Exp $ */
14 /*************************** SIGTRP *************************************
15 * The monitor call "sigtrp()" is handled by "do_sigtrp()". The first *
16 * argument is a EM-trap number (0<=tn<=252), the second a UNIX signal *
17 * number. The user wants trap "tn" to be generated, in case signal *
18 * "sn" occurs. The report about this interpreter has a section, *
19 * giving all details about signal handling. Do_sigtrp() returns the *
20 * previous trap-number "sn" was mapped onto. A return value of -1 *
21 * indicates an error. *
22 ************************************************************************/
24 #define UNIX_trap(sn) (SIGILL <= sn && sn <= SIGSYS)
29 PRIVATE int sig_map[NSIG+1]; /* maps signals onto trap numbers */
31 PRIVATE void HndlIntSig(); /* handle signal to interpreter */
32 PRIVATE void HndlEmSig(); /* handle signal to user program */
37 for (sn = 0; sn < NSIG+1; sn++) {
38 sig_map[sn] = -2; /* Default EM trap number */
41 for (sn = 0; sn < NSIG+1; sn++) {
42 /* for all signals that would cause termination */
45 if (sn == SIGCHLD) continue;
48 if (sn == SIGIO) continue;
51 if (sn == SIGWINCH) continue;
53 if (signal(sn, SIG_IGN) != SIG_IGN) {
54 /* we take our fate in our own hand */
55 signal(sn, HndlIntSig);
62 int tn; /* EM trap number */
63 int sn; /* UNIX signal number */
67 if (sn <= 0 || sn > NSIG) {
79 if (tn == -2) { /* reset default for signal sn */
82 else if (tn == -3) { /* ignore signal sn */
85 else if (tn >= 0 && tn <= 252) {/* legal tn */
86 if ((int)signal(sn, HndlEmSig) == -1) {
92 /* illegal trap number */
94 sig_map[sn] = old_tn; /* restore sig_map */
102 /* execute the trap belonging to the signal that came in during
105 register int old_sig = signalled;
108 trap(sig_map[old_sig]);
111 /* The handling functions for the UNIX signals */
113 PRIVATE void HndlIntSig(sn)
116 /* The interpreter got the signal */
117 signal(sn, SIG_IGN); /* peace and quiet for close_down() */
118 LOG(("@t1 signal %d caught by interpreter", sn));
119 message("interpreter received signal %d, which was not caught by the interpreted program",
124 PRIVATE void HndlEmSig(sn)
127 /* The EM machine got the signal */
128 signal(sn, HndlIntSig); /* Revert to old situation */