Deleted Added
full compact
signals.c (136644) signals.c (157184)
1/* signals.c -- signal handling support for readline. */
2
1/* signals.c -- signal handling support for readline. */
2
3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
3/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2, or
11 (at your option) any later version.

--- 114 unchanged lines hidden (view full) ---

126# endif /* !HAVE_BSD_SIGNALS */
127#endif /* !HAVE_POSIX_SIGNALS */
128
129 RL_SETSTATE(RL_STATE_SIGHANDLER);
130
131#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
132 /* Since the signal will not be blocked while we are in the signal
133 handler, ignore it until rl_clear_signals resets the catcher. */
4
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
7
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2, or
11 (at your option) any later version.

--- 114 unchanged lines hidden (view full) ---

126# endif /* !HAVE_BSD_SIGNALS */
127#endif /* !HAVE_POSIX_SIGNALS */
128
129 RL_SETSTATE(RL_STATE_SIGHANDLER);
130
131#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
132 /* Since the signal will not be blocked while we are in the signal
133 handler, ignore it until rl_clear_signals resets the catcher. */
134# if defined (SIGALRM)
134 if (sig == SIGINT || sig == SIGALRM)
135 if (sig == SIGINT || sig == SIGALRM)
136# else
137 if (sig == SIGINT)
138# endif
135 rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
136#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
137
138 switch (sig)
139 {
140 case SIGINT:
141 rl_free_line_state ();
142 /* FALLTHROUGH */
143
139 rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
140#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
141
142 switch (sig)
143 {
144 case SIGINT:
145 rl_free_line_state ();
146 /* FALLTHROUGH */
147
148 case SIGTERM:
144#if defined (SIGTSTP)
145 case SIGTSTP:
146 case SIGTTOU:
147 case SIGTTIN:
148#endif /* SIGTSTP */
149#if defined (SIGTSTP)
150 case SIGTSTP:
151 case SIGTTOU:
152 case SIGTTIN:
153#endif /* SIGTSTP */
154#if defined (SIGALRM)
149 case SIGALRM:
155 case SIGALRM:
150 case SIGTERM:
156#endif
157#if defined (SIGQUIT)
151 case SIGQUIT:
158 case SIGQUIT:
159#endif
152 rl_cleanup_after_signal ();
153
154#if defined (HAVE_POSIX_SIGNALS)
155 sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
156 sigdelset (&set, sig);
157#else /* !HAVE_POSIX_SIGNALS */
158# if defined (HAVE_BSD_SIGNALS)
159 omask = sigblock (0);
160# endif /* HAVE_BSD_SIGNALS */
161#endif /* !HAVE_POSIX_SIGNALS */
162
163#if defined (__EMX__)
164 signal (sig, SIG_ACK);
165#endif
166
160 rl_cleanup_after_signal ();
161
162#if defined (HAVE_POSIX_SIGNALS)
163 sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
164 sigdelset (&set, sig);
165#else /* !HAVE_POSIX_SIGNALS */
166# if defined (HAVE_BSD_SIGNALS)
167 omask = sigblock (0);
168# endif /* HAVE_BSD_SIGNALS */
169#endif /* !HAVE_POSIX_SIGNALS */
170
171#if defined (__EMX__)
172 signal (sig, SIG_ACK);
173#endif
174
175#if defined (HAVE_KILL)
167 kill (getpid (), sig);
176 kill (getpid (), sig);
177#else
178 raise (sig); /* assume we have raise */
179#endif
168
169 /* Let the signal that we just sent through. */
170#if defined (HAVE_POSIX_SIGNALS)
171 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
172#else /* !HAVE_POSIX_SIGNALS */
173# if defined (HAVE_BSD_SIGNALS)
174 sigsetmask (omask & ~(sigmask (sig)));
175# endif /* HAVE_BSD_SIGNALS */

--- 100 unchanged lines hidden (view full) ---

276{
277 sighandler_cxt dummy;
278 SigHandler *oh;
279
280 if (rl_catch_signals && signals_set_flag == 0)
281 {
282 rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
283 rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
180
181 /* Let the signal that we just sent through. */
182#if defined (HAVE_POSIX_SIGNALS)
183 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
184#else /* !HAVE_POSIX_SIGNALS */
185# if defined (HAVE_BSD_SIGNALS)
186 sigsetmask (omask & ~(sigmask (sig)));
187# endif /* HAVE_BSD_SIGNALS */

--- 100 unchanged lines hidden (view full) ---

288{
289 sighandler_cxt dummy;
290 SigHandler *oh;
291
292 if (rl_catch_signals && signals_set_flag == 0)
293 {
294 rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
295 rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
296#if defined (SIGQUIT)
284 rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
297 rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
298#endif
285
299
300#if defined (SIGALRM)
286 oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
287 if (oh == (SigHandler *)SIG_IGN)
288 rl_sigaction (SIGALRM, &old_alrm, &dummy);
289#if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART)
290 /* If the application using readline has already installed a signal
291 handler with SA_RESTART, SIGALRM will cause reads to be restarted
292 automatically, so readline should just get out of the way. Since
293 we tested for SIG_IGN above, we can just test for SIG_DFL here. */
294 if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
295 rl_sigaction (SIGALRM, &old_alrm, &dummy);
296#endif /* HAVE_POSIX_SIGNALS */
301 oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
302 if (oh == (SigHandler *)SIG_IGN)
303 rl_sigaction (SIGALRM, &old_alrm, &dummy);
304#if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART)
305 /* If the application using readline has already installed a signal
306 handler with SA_RESTART, SIGALRM will cause reads to be restarted
307 automatically, so readline should just get out of the way. Since
308 we tested for SIG_IGN above, we can just test for SIG_DFL here. */
309 if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
310 rl_sigaction (SIGALRM, &old_alrm, &dummy);
311#endif /* HAVE_POSIX_SIGNALS */
312#endif /* SIGALRM */
297
298#if defined (SIGTSTP)
299 rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
300#endif /* SIGTSTP */
301
302#if defined (SIGTTOU)
303 rl_maybe_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
304#endif /* SIGTTOU */

--- 22 unchanged lines hidden (view full) ---

327 sighandler_cxt dummy;
328
329 if (rl_catch_signals && signals_set_flag == 1)
330 {
331 sigemptyset (&dummy.sa_mask);
332
333 rl_sigaction (SIGINT, &old_int, &dummy);
334 rl_sigaction (SIGTERM, &old_term, &dummy);
313
314#if defined (SIGTSTP)
315 rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
316#endif /* SIGTSTP */
317
318#if defined (SIGTTOU)
319 rl_maybe_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
320#endif /* SIGTTOU */

--- 22 unchanged lines hidden (view full) ---

343 sighandler_cxt dummy;
344
345 if (rl_catch_signals && signals_set_flag == 1)
346 {
347 sigemptyset (&dummy.sa_mask);
348
349 rl_sigaction (SIGINT, &old_int, &dummy);
350 rl_sigaction (SIGTERM, &old_term, &dummy);
351#if defined (SIGQUIT)
335 rl_sigaction (SIGQUIT, &old_quit, &dummy);
352 rl_sigaction (SIGQUIT, &old_quit, &dummy);
353#endif
354#if defined (SIGALRM)
336 rl_sigaction (SIGALRM, &old_alrm, &dummy);
355 rl_sigaction (SIGALRM, &old_alrm, &dummy);
356#endif
337
338#if defined (SIGTSTP)
339 rl_sigaction (SIGTSTP, &old_tstp, &dummy);
340#endif /* SIGTSTP */
341
342#if defined (SIGTTOU)
343 rl_sigaction (SIGTTOU, &old_ttou, &dummy);
344#endif /* SIGTTOU */

--- 18 unchanged lines hidden (view full) ---

363}
364
365/* Clean up the terminal and readline state after catching a signal, before
366 resending it to the calling application. */
367void
368rl_cleanup_after_signal ()
369{
370 _rl_clean_up_for_exit ();
357
358#if defined (SIGTSTP)
359 rl_sigaction (SIGTSTP, &old_tstp, &dummy);
360#endif /* SIGTSTP */
361
362#if defined (SIGTTOU)
363 rl_sigaction (SIGTTOU, &old_ttou, &dummy);
364#endif /* SIGTTOU */

--- 18 unchanged lines hidden (view full) ---

383}
384
385/* Clean up the terminal and readline state after catching a signal, before
386 resending it to the calling application. */
387void
388rl_cleanup_after_signal ()
389{
390 _rl_clean_up_for_exit ();
371 (*rl_deprep_term_function) ();
391 if (rl_deprep_term_function)
392 (*rl_deprep_term_function) ();
372 rl_clear_signals ();
373 rl_clear_pending_input ();
374}
375
376/* Reset the terminal and readline state after a signal handler returns. */
377void
378rl_reset_after_signal ()
379{
393 rl_clear_signals ();
394 rl_clear_pending_input ();
395}
396
397/* Reset the terminal and readline state after a signal handler returns. */
398void
399rl_reset_after_signal ()
400{
380 (*rl_prep_term_function) (_rl_meta_flag);
401 if (rl_prep_term_function)
402 (*rl_prep_term_function) (_rl_meta_flag);
381 rl_set_signals ();
382}
383
384/* Free up the readline variable line state for the current line (undo list,
385 any partial history entry, any keyboard macros in progress, and any
386 numeric arguments in process) after catching a signal, before calling
387 rl_cleanup_after_signal(). */
388void

--- 4 unchanged lines hidden (view full) ---

393 rl_free_undo_list ();
394
395 entry = current_history ();
396 if (entry)
397 entry->data = (char *)NULL;
398
399 _rl_kill_kbd_macro ();
400 rl_clear_message ();
403 rl_set_signals ();
404}
405
406/* Free up the readline variable line state for the current line (undo list,
407 any partial history entry, any keyboard macros in progress, and any
408 numeric arguments in process) after catching a signal, before calling
409 rl_cleanup_after_signal(). */
410void

--- 4 unchanged lines hidden (view full) ---

415 rl_free_undo_list ();
416
417 entry = current_history ();
418 if (entry)
419 entry->data = (char *)NULL;
420
421 _rl_kill_kbd_macro ();
422 rl_clear_message ();
401 _rl_init_argument ();
423 _rl_reset_argument ();
402}
403
404#endif /* HANDLE_SIGNALS */
424}
425
426#endif /* HANDLE_SIGNALS */