2 * Routines dealing with signals.
4 * A signal usually merely causes a bit to be set in the "signals" word.
5 * At some convenient time, the mainline code checks to see if any
6 * signals need processing by calling psignal().
7 * If we happen to be reading from a file [in iread()] at the time
8 * the signal is received, we call intread to interrupt the iread.
15 * "sigs" contains bits indicating signals which need to be processed.
19 #define S_INTERRUPT 01
23 #if defined(SIGWINCH) || defined(SIGWIND)
27 extern int sc_width, sc_height;
29 extern int screen_trashed;
36 * Interrupt signal handler.
43 SIGNAL(SIGINT, u_interrupt);
57 * "Stop" (^Z) signal handler.
64 SIGNAL(SIGTSTP, stop);
73 * "Window" change handler
80 SIGNAL(SIGWINCH, winch);
88 * "Window" change handler
95 SIGNAL(SIGWIND, winch);
104 * Set up the signal handlers.
113 * Set signal handlers.
115 (void) SIGNAL(SIGINT, u_interrupt);
117 (void) SIGNAL(SIGTSTP, stop);
120 (void) SIGNAL(SIGWINCH, winch);
123 (void) SIGNAL(SIGWIND, winch);
129 * Restore signals to defaults.
131 (void) SIGNAL(SIGINT, SIG_DFL);
133 (void) SIGNAL(SIGTSTP, SIG_DFL);
136 (void) SIGNAL(SIGWINCH, SIG_IGN);
139 (void) SIGNAL(SIGWIND, SIG_IGN);
145 * Process any signals we have received.
146 * A received signal cause a bit to be set in "sigs".
151 register int tsignals;
153 if ((tsignals = sigs) == 0)
158 if (tsignals & S_WINCH)
160 int old_width, old_height;
162 * Re-execute get_term() to read the new window size.
164 old_width = sc_width;
165 old_height = sc_height;
168 if (sc_width != old_width || sc_height != old_height)
170 scroll = (sc_height + 1) / 2;
176 if (tsignals & S_STOP)
179 * Clean up the terminal.
182 SIGNAL(SIGTTOU, SIG_IGN);
190 SIGNAL(SIGTTOU, SIG_DFL);
192 SIGNAL(SIGTSTP, SIG_DFL);
193 kill(getpid(), SIGTSTP);
196 * Hopefully we'll be back later and resume here...
197 * Reset the terminal and arrange to repaint the
198 * screen when we get back to the main command loop.
200 SIGNAL(SIGTSTP, stop);
206 if (tsignals & S_INTERRUPT)
210 * {{ You may wish to replace the bell() with
211 * error("Interrupt", NULL_PARG); }}
215 * If we were interrupted while in the "calculating
216 * line numbers" loop, turn off line numbers.
224 error("Line numbers turned off", NULL_PARG);