- init_signals ();
- emacs_sigaction_init (&fatal_error_action, deliver_fatal_signal);
-
- /* Don't catch SIGHUP if dumping. */
- if (1
-#ifndef CANNOT_DUMP
- && initialized
-#endif
- )
- {
- /* In --batch mode, don't catch SIGHUP if already ignored.
- That makes nohup work. */
- bool catch_SIGHUP = !noninteractive;
- if (!catch_SIGHUP)
- {
- struct sigaction old_action;
- sigaction (SIGHUP, 0, &old_action);
- catch_SIGHUP = old_action.sa_handler != SIG_IGN;
- }
- if (catch_SIGHUP)
- sigaction (SIGHUP, &fatal_error_action, 0);
- }
-
- if (
-#ifndef CANNOT_DUMP
- ! noninteractive || initialized
-#else
- 1
-#endif
- )
- {
- /* Don't catch these signals in batch mode if dumping.
- On some machines, this sets static data that would make
- signal fail to work right when the dumped Emacs is run. */
- sigaction (SIGQUIT, &fatal_error_action, 0);
- sigaction (SIGILL, &fatal_error_action, 0);
- sigaction (SIGTRAP, &fatal_error_action, 0);
-#ifdef SIGUSR1
- add_user_signal (SIGUSR1, "sigusr1");
-#endif
-#ifdef SIGUSR2
- add_user_signal (SIGUSR2, "sigusr2");
-#endif
-#ifdef SIGABRT
- sigaction (SIGABRT, &fatal_error_action, 0);
-#endif
-#ifdef SIGHWE
- sigaction (SIGHWE, &fatal_error_action, 0);
-#endif
-#ifdef SIGPRE
- sigaction (SIGPRE, &fatal_error_action, 0);
-#endif
-#ifdef SIGORE
- sigaction (SIGORE, &fatal_error_action, 0);
-#endif
-#ifdef SIGUME
- sigaction (SIGUME, &fatal_error_action, 0);
-#endif
-#ifdef SIGDLK
- sigaction (SIGDLK, &fatal_error_action, 0);
-#endif
-#ifdef SIGCPULIM
- sigaction (SIGCPULIM, &fatal_error_action, 0);
-#endif
-#ifdef SIGIOT
- /* This is missing on some systems - OS/2, for example. */
- sigaction (SIGIOT, &fatal_error_action, 0);
-#endif
-#ifdef SIGEMT
- sigaction (SIGEMT, &fatal_error_action, 0);
-#endif
- sigaction (SIGFPE, &fatal_error_action, 0);
-#ifdef SIGBUS
- sigaction (SIGBUS, &fatal_error_action, 0);
-#endif
- sigaction (SIGSEGV, &fatal_error_action, 0);
-#ifdef SIGSYS
- sigaction (SIGSYS, &fatal_error_action, 0);
-#endif
- /* May need special treatment on MS-Windows. See
- http://lists.gnu.org/archive/html/emacs-devel/2010-09/msg01062.html
- Please update the doc of kill-emacs, kill-emacs-hook, and
- NEWS if you change this.
- */
- if (noninteractive)
- sigaction (SIGINT, &fatal_error_action, 0);
- sigaction (SIGTERM, &fatal_error_action, 0);
-#ifdef SIGXCPU
- sigaction (SIGXCPU, &fatal_error_action, 0);
-#endif
-#ifdef SIGXFSZ
- sigaction (SIGXFSZ, &fatal_error_action, 0);
-#endif /* SIGXFSZ */
-
-#ifdef SIGDANGER
- /* This just means available memory is getting low. */
- {
- struct sigaction action;
- emacs_sigaction_init (&action, deliver_danger_signal);
- sigaction (SIGDANGER, &action, 0);
- }
-#endif
-
-#ifdef AIX
-/* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
- sigaction (SIGXCPU, &fatal_error_action, 0);
- sigaction (SIGIOINT, &fatal_error_action, 0);
- sigaction (SIGGRANT, &fatal_error_action, 0);
- sigaction (SIGRETRACT, &fatal_error_action, 0);
- sigaction (SIGSOUND, &fatal_error_action, 0);
- sigaction (SIGMSG, &fatal_error_action, 0);
-#endif /* AIX */
- }