aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-12-07 18:30:51 -0800
committerPaul Eggert2012-12-07 18:30:51 -0800
commitd983a10b9a070fd8f6d4f48ec44e5514b62feaa6 (patch)
tree1b7353b39c508615eb0d2cf4475fdfabf8ef6ce0 /src
parent9cdde1e2dfdd7b1a4e52294bca1467dc7a48c77a (diff)
downloademacs-d983a10b9a070fd8f6d4f48ec44e5514b62feaa6.tar.gz
emacs-d983a10b9a070fd8f6d4f48ec44e5514b62feaa6.zip
Assume POSIX 1003.1-1988 or later for signal.h.
Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these. * admin/CPP-DEFINES (SIGALRM, SIGCHLD, SIGHUP, SIGKILL, SIGPIPE, SIGQUIT): Remove. (SIGTRAP): Remove this one too, as config.h no longer defines it. * admin/merge-gnulib (GNULIB_MODULES): Add sig2str. * configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF): Use SIGCHLD rather than SIGCLD. * lib/sig2str.c, lib/sig2str.h, m4/sig2str.m4: New files, from gnulib. * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. * lib/makefile.w32-in (GNULIBOBJS): Add $(BUILD)/sig2str.$(O). * src/process.c [subprocesses]: Include <c-ctype.h>, <sig2str.h>. (deleted_pid_list, Fdelete_process, create_process) (record_child_status_change, handle_child_signal, deliver_child_signal) (init_process_emacs, syms_of_process): Assume SIGCHLD is defined. (parse_signal): Remove. All uses removed. (abbr_to_signal): New static function. (Fsignal_process): Use it to convert signal names to ints. * src/sysdep.c (sys_suspend) [!DOS_NT]: Use kill (0, ...) rather than kill (getpgrp (), ...). (emacs_sigaction_init): Assume SIGCHLD is defined. (init_signals): Assume SIGALRM, SIGCHLD, SIGHUP, SIGKILL, SIGPIPE, and SIGQUIT are defined. Do not worry about SIGCLD any more. * src/syssignal.h (EMACS_KILLPG): Remove. All uses replaced by 'kill' with a negative pid. (SIGCHLD): Remove definition, as we now assume SIGCHLD. * src/w32proc.c (sys_kill): Support negative pids compatibly with POSIX. Fixes: debbugs:13026
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog23
-rw-r--r--src/callproc.c8
-rw-r--r--src/keyboard.c2
-rw-r--r--src/process.c156
-rw-r--r--src/sysdep.c30
-rw-r--r--src/syssignal.h20
-rw-r--r--src/w32proc.c4
7 files changed, 70 insertions, 173 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index edd6924af50..2b283a609e3 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,26 @@
12012-12-08 Paul Eggert <eggert@cs.ucla.edu>
2
3 Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
4 Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN,
5 SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these.
6 * process.c [subprocesses]: Include <c-ctype.h>, <sig2str.h>.
7 (deleted_pid_list, Fdelete_process, create_process)
8 (record_child_status_change, handle_child_signal, deliver_child_signal)
9 (init_process_emacs, syms_of_process):
10 Assume SIGCHLD is defined.
11 (parse_signal): Remove. All uses removed.
12 (abbr_to_signal): New static function.
13 (Fsignal_process): Use it to convert signal names to ints.
14 * sysdep.c (sys_suspend) [!DOS_NT]: Use kill (0, ...) rather than
15 kill (getpgrp (), ...).
16 (emacs_sigaction_init): Assume SIGCHLD is defined.
17 (init_signals): Assume SIGALRM, SIGCHLD, SIGHUP, SIGKILL,
18 SIGPIPE, and SIGQUIT are defined. Do not worry about SIGCLD any more.
19 * syssignal.h (EMACS_KILLPG): Remove.
20 All uses replaced by 'kill' with a negative pid.
21 (SIGCHLD): Remove definition, as we now assume SIGCHLD.
22 * w32proc.c (sys_kill): Support negative pids compatibly with POSIX.
23
12012-12-07 Paul Eggert <eggert@cs.ucla.edu> 242012-12-07 Paul Eggert <eggert@cs.ucla.edu>
2 25
3 * sysdep.c (get_child_status): Abort on internal error (Bug#13086). 26 * sysdep.c (get_child_status): Abort on internal error (Bug#13086).
diff --git a/src/callproc.c b/src/callproc.c
index e0528a791ea..70e349d0d3a 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -87,12 +87,10 @@ static int synch_process_fd;
87static void 87static void
88block_child_signal (void) 88block_child_signal (void)
89{ 89{
90#ifdef SIGCHLD
91 sigset_t blocked; 90 sigset_t blocked;
92 sigemptyset (&blocked); 91 sigemptyset (&blocked);
93 sigaddset (&blocked, SIGCHLD); 92 sigaddset (&blocked, SIGCHLD);
94 pthread_sigmask (SIG_BLOCK, &blocked, 0); 93 pthread_sigmask (SIG_BLOCK, &blocked, 0);
95#endif
96} 94}
97 95
98/* Unblock SIGCHLD. */ 96/* Unblock SIGCHLD. */
@@ -100,9 +98,7 @@ block_child_signal (void)
100static void 98static void
101unblock_child_signal (void) 99unblock_child_signal (void)
102{ 100{
103#ifdef SIGCHLD
104 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 101 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
105#endif
106} 102}
107 103
108/* If P is reapable, record it as a deleted process and kill it. 104/* If P is reapable, record it as a deleted process and kill it.
@@ -118,7 +114,7 @@ record_kill_process (struct Lisp_Process *p)
118 { 114 {
119 p->alive = 0; 115 p->alive = 0;
120 record_deleted_pid (p->pid); 116 record_deleted_pid (p->pid);
121 EMACS_KILLPG (p->pid, SIGKILL); 117 kill (- p->pid, SIGKILL);
122 } 118 }
123 119
124 unblock_child_signal (); 120 unblock_child_signal ();
@@ -164,7 +160,7 @@ call_process_cleanup (Lisp_Object arg)
164 if (synch_process_pid) 160 if (synch_process_pid)
165 { 161 {
166 ptrdiff_t count = SPECPDL_INDEX (); 162 ptrdiff_t count = SPECPDL_INDEX ();
167 EMACS_KILLPG (synch_process_pid, SIGINT); 163 kill (-synch_process_pid, SIGINT);
168 record_unwind_protect (call_process_kill, make_number (0)); 164 record_unwind_protect (call_process_kill, make_number (0));
169 message1 ("Waiting for process to die...(type C-g again to kill it instantly)"); 165 message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
170 immediate_quit = 1; 166 immediate_quit = 1;
diff --git a/src/keyboard.c b/src/keyboard.c
index 1bb4c85dd7b..fc155c5a5f7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -10688,7 +10688,7 @@ handle_interrupt (bool in_signal_handler)
10688 fflush (stdout); 10688 fflush (stdout);
10689 reset_all_sys_modes (); 10689 reset_all_sys_modes ();
10690 10690
10691#ifdef SIGTSTP /* Support possible in later USG versions */ 10691#ifdef SIGTSTP
10692/* 10692/*
10693 * On systems which can suspend the current process and return to the original 10693 * On systems which can suspend the current process and return to the original
10694 * shell, this command causes the user to end up back at the shell. 10694 * shell, this command causes the user to end up back at the shell.
diff --git a/src/process.c b/src/process.c
index 007a07942e6..7b21d060cf8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -91,6 +91,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
91#include <pty.h> 91#include <pty.h>
92#endif 92#endif
93 93
94#include <c-ctype.h>
95#include <sig2str.h>
96
94#endif /* subprocesses */ 97#endif /* subprocesses */
95 98
96#include "systime.h" 99#include "systime.h"
@@ -773,7 +776,6 @@ get_process (register Lisp_Object name)
773} 776}
774 777
775 778
776#ifdef SIGCHLD
777/* Fdelete_process promises to immediately forget about the process, but in 779/* Fdelete_process promises to immediately forget about the process, but in
778 reality, Emacs needs to remember those processes until they have been 780 reality, Emacs needs to remember those processes until they have been
779 treated by the SIGCHLD handler and waitpid has been invoked on them; 781 treated by the SIGCHLD handler and waitpid has been invoked on them;
@@ -781,17 +783,14 @@ get_process (register Lisp_Object name)
781 783
782 Some processes created by call-process are also put onto this list. */ 784 Some processes created by call-process are also put onto this list. */
783static Lisp_Object deleted_pid_list; 785static Lisp_Object deleted_pid_list;
784#endif
785 786
786void 787void
787record_deleted_pid (pid_t pid) 788record_deleted_pid (pid_t pid)
788{ 789{
789#ifdef SIGCHLD
790 deleted_pid_list = Fcons (make_fixnum_or_float (pid), 790 deleted_pid_list = Fcons (make_fixnum_or_float (pid),
791 /* GC treated elements set to nil. */ 791 /* GC treated elements set to nil. */
792 Fdelq (Qnil, deleted_pid_list)); 792 Fdelq (Qnil, deleted_pid_list));
793 793
794#endif
795} 794}
796 795
797DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0, 796DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
@@ -1581,9 +1580,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1581#ifndef WINDOWSNT 1580#ifndef WINDOWSNT
1582 int wait_child_setup[2]; 1581 int wait_child_setup[2];
1583#endif 1582#endif
1584#ifdef SIGCHLD
1585 sigset_t blocked; 1583 sigset_t blocked;
1586#endif
1587 /* Use volatile to protect variables from being clobbered by vfork. */ 1584 /* Use volatile to protect variables from being clobbered by vfork. */
1588 volatile int forkin, forkout; 1585 volatile int forkin, forkout;
1589 volatile int pty_flag = 0; 1586 volatile int pty_flag = 0;
@@ -1680,13 +1677,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1680 1677
1681 block_input (); 1678 block_input ();
1682 1679
1683#ifdef SIGCHLD
1684 /* Block SIGCHLD until we have a chance to store the new fork's 1680 /* Block SIGCHLD until we have a chance to store the new fork's
1685 pid in its process structure. */ 1681 pid in its process structure. */
1686 sigemptyset (&blocked); 1682 sigemptyset (&blocked);
1687 sigaddset (&blocked, SIGCHLD); 1683 sigaddset (&blocked, SIGCHLD);
1688 pthread_sigmask (SIG_BLOCK, &blocked, 0); 1684 pthread_sigmask (SIG_BLOCK, &blocked, 0);
1689#endif
1690 1685
1691#ifndef WINDOWSNT 1686#ifndef WINDOWSNT
1692 pid = vfork (); 1687 pid = vfork ();
@@ -1794,10 +1789,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1794 /* Emacs ignores SIGPIPE, but the child should not. */ 1789 /* Emacs ignores SIGPIPE, but the child should not. */
1795 signal (SIGPIPE, SIG_DFL); 1790 signal (SIGPIPE, SIG_DFL);
1796 1791
1797#ifdef SIGCHLD
1798 /* Stop blocking signals in the child. */ 1792 /* Stop blocking signals in the child. */
1799 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 1793 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
1800#endif
1801 1794
1802 if (pty_flag) 1795 if (pty_flag)
1803 child_setup_tty (xforkout); 1796 child_setup_tty (xforkout);
@@ -1818,9 +1811,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1818 XPROCESS (process)->alive = 1; 1811 XPROCESS (process)->alive = 1;
1819 1812
1820 /* Stop blocking signals in the parent. */ 1813 /* Stop blocking signals in the parent. */
1821#ifdef SIGCHLD
1822 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 1814 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
1823#endif
1824 unblock_input (); 1815 unblock_input ();
1825 1816
1826 if (pid < 0) 1817 if (pid < 0)
@@ -4612,7 +4603,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4612 yielding EBADF here or at select() call above. 4603 yielding EBADF here or at select() call above.
4613 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF 4604 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
4614 in m/ibmrt-aix.h), and here we just ignore the select error. 4605 in m/ibmrt-aix.h), and here we just ignore the select error.
4615 Cleanup occurs c/o status_notify after SIGCLD. */ 4606 Cleanup occurs c/o status_notify after SIGCHLD. */
4616 no_avail = 1; /* Cannot depend on values returned */ 4607 no_avail = 1; /* Cannot depend on values returned */
4617#else 4608#else
4618 emacs_abort (); 4609 emacs_abort ();
@@ -4810,10 +4801,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4810#endif /* HAVE_PTYS */ 4801#endif /* HAVE_PTYS */
4811 /* If we can detect process termination, don't consider the 4802 /* If we can detect process termination, don't consider the
4812 process gone just because its pipe is closed. */ 4803 process gone just because its pipe is closed. */
4813#ifdef SIGCHLD
4814 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) 4804 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc))
4815 ; 4805 ;
4816#endif
4817 else 4806 else
4818 { 4807 {
4819 /* Preserve status of processes already terminated. */ 4808 /* Preserve status of processes already terminated. */
@@ -5676,7 +5665,7 @@ return t unconditionally. */)
5676 5665
5677 If we can, we try to signal PROCESS by sending control characters 5666 If we can, we try to signal PROCESS by sending control characters
5678 down the pty. This allows us to signal inferiors who have changed 5667 down the pty. This allows us to signal inferiors who have changed
5679 their uid, for which killpg would return an EPERM error. */ 5668 their uid, for which kill would return an EPERM error. */
5680 5669
5681static void 5670static void
5682process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, 5671process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
@@ -5814,7 +5803,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
5814 if (!NILP (current_group)) 5803 if (!NILP (current_group))
5815 { 5804 {
5816 if (ioctl (p->infd, TIOCSIGSEND, signo) == -1) 5805 if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
5817 EMACS_KILLPG (gid, signo); 5806 kill (-gid, signo);
5818 } 5807 }
5819 else 5808 else
5820 { 5809 {
@@ -5822,7 +5811,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
5822 kill (gid, signo); 5811 kill (gid, signo);
5823 } 5812 }
5824#else /* ! defined (TIOCSIGSEND) */ 5813#else /* ! defined (TIOCSIGSEND) */
5825 EMACS_KILLPG (gid, signo); 5814 kill (-gid, signo);
5826#endif /* ! defined (TIOCSIGSEND) */ 5815#endif /* ! defined (TIOCSIGSEND) */
5827} 5816}
5828 5817
@@ -5927,6 +5916,27 @@ traffic. */)
5927 return process; 5916 return process;
5928} 5917}
5929 5918
5919/* Return the integer value of the signal whose abbreviation is ABBR,
5920 or a negative number if there is no such signal. */
5921static int
5922abbr_to_signal (char const *name)
5923{
5924 int i, signo;
5925 char sigbuf[20]; /* Large enough for all valid signal abbreviations. */
5926
5927 if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
5928 name += 3;
5929
5930 for (i = 0; i < sizeof sigbuf; i++)
5931 {
5932 sigbuf[i] = c_toupper (name[i]);
5933 if (! sigbuf[i])
5934 return str2sig (sigbuf, &signo) == 0 ? signo : -1;
5935 }
5936
5937 return -1;
5938}
5939
5930DEFUN ("signal-process", Fsignal_process, Ssignal_process, 5940DEFUN ("signal-process", Fsignal_process, Ssignal_process,
5931 2, 2, "sProcess (name or number): \nnSignal code: ", 5941 2, 2, "sProcess (name or number): \nnSignal code: ",
5932 doc: /* Send PROCESS the signal with code SIGCODE. 5942 doc: /* Send PROCESS the signal with code SIGCODE.
@@ -5937,6 +5947,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
5937 (Lisp_Object process, Lisp_Object sigcode) 5947 (Lisp_Object process, Lisp_Object sigcode)
5938{ 5948{
5939 pid_t pid; 5949 pid_t pid;
5950 int signo;
5940 5951
5941 if (STRINGP (process)) 5952 if (STRINGP (process))
5942 { 5953 {
@@ -5966,12 +5977,11 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
5966 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); 5977 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
5967 } 5978 }
5968 5979
5969#define parse_signal(NAME, VALUE) \
5970 else if (!xstrcasecmp (name, NAME)) \
5971 XSETINT (sigcode, VALUE)
5972
5973 if (INTEGERP (sigcode)) 5980 if (INTEGERP (sigcode))
5974 CHECK_TYPE_RANGED_INTEGER (int, sigcode); 5981 {
5982 CHECK_TYPE_RANGED_INTEGER (int, sigcode);
5983 signo = XINT (sigcode);
5984 }
5975 else 5985 else
5976 { 5986 {
5977 char *name; 5987 char *name;
@@ -5979,96 +5989,12 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
5979 CHECK_SYMBOL (sigcode); 5989 CHECK_SYMBOL (sigcode);
5980 name = SSDATA (SYMBOL_NAME (sigcode)); 5990 name = SSDATA (SYMBOL_NAME (sigcode));
5981 5991
5982 if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3)) 5992 signo = abbr_to_signal (name);
5983 name += 3; 5993 if (signo < 0)
5984
5985 if (0)
5986 ;
5987#ifdef SIGUSR1
5988 parse_signal ("usr1", SIGUSR1);
5989#endif
5990#ifdef SIGUSR2
5991 parse_signal ("usr2", SIGUSR2);
5992#endif
5993 parse_signal ("term", SIGTERM);
5994#ifdef SIGHUP
5995 parse_signal ("hup", SIGHUP);
5996#endif
5997 parse_signal ("int", SIGINT);
5998#ifdef SIGQUIT
5999 parse_signal ("quit", SIGQUIT);
6000#endif
6001 parse_signal ("ill", SIGILL);
6002 parse_signal ("abrt", SIGABRT);
6003#ifdef SIGEMT
6004 parse_signal ("emt", SIGEMT);
6005#endif
6006#ifdef SIGKILL
6007 parse_signal ("kill", SIGKILL);
6008#endif
6009 parse_signal ("fpe", SIGFPE);
6010#ifdef SIGBUS
6011 parse_signal ("bus", SIGBUS);
6012#endif
6013 parse_signal ("segv", SIGSEGV);
6014#ifdef SIGSYS
6015 parse_signal ("sys", SIGSYS);
6016#endif
6017#ifdef SIGPIPE
6018 parse_signal ("pipe", SIGPIPE);
6019#endif
6020#ifdef SIGALRM
6021 parse_signal ("alrm", SIGALRM);
6022#endif
6023#ifdef SIGURG
6024 parse_signal ("urg", SIGURG);
6025#endif
6026#ifdef SIGSTOP
6027 parse_signal ("stop", SIGSTOP);
6028#endif
6029#ifdef SIGTSTP
6030 parse_signal ("tstp", SIGTSTP);
6031#endif
6032#ifdef SIGCONT
6033 parse_signal ("cont", SIGCONT);
6034#endif
6035#ifdef SIGCHLD
6036 parse_signal ("chld", SIGCHLD);
6037#endif
6038#ifdef SIGTTIN
6039 parse_signal ("ttin", SIGTTIN);
6040#endif
6041#ifdef SIGTTOU
6042 parse_signal ("ttou", SIGTTOU);
6043#endif
6044#ifdef SIGIO
6045 parse_signal ("io", SIGIO);
6046#endif
6047#ifdef SIGXCPU
6048 parse_signal ("xcpu", SIGXCPU);
6049#endif
6050#ifdef SIGXFSZ
6051 parse_signal ("xfsz", SIGXFSZ);
6052#endif
6053#ifdef SIGVTALRM
6054 parse_signal ("vtalrm", SIGVTALRM);
6055#endif
6056#ifdef SIGPROF
6057 parse_signal ("prof", SIGPROF);
6058#endif
6059#ifdef SIGWINCH
6060 parse_signal ("winch", SIGWINCH);
6061#endif
6062#ifdef SIGINFO
6063 parse_signal ("info", SIGINFO);
6064#endif
6065 else
6066 error ("Undefined signal name %s", name); 5994 error ("Undefined signal name %s", name);
6067 } 5995 }
6068 5996
6069#undef parse_signal 5997 return make_number (kill (pid, signo));
6070
6071 return make_number (kill (pid, XINT (sigcode)));
6072} 5998}
6073 5999
6074DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, 6000DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
@@ -6150,8 +6076,6 @@ process has been transmitted to the serial port. */)
6150 return process; 6076 return process;
6151} 6077}
6152 6078
6153#ifdef SIGCHLD
6154
6155/* The main Emacs thread records child processes in three places: 6079/* The main Emacs thread records child processes in three places:
6156 6080
6157 - Vprocess_alist, for asynchronous subprocesses, which are child 6081 - Vprocess_alist, for asynchronous subprocesses, which are child
@@ -6268,8 +6192,6 @@ deliver_child_signal (int sig)
6268{ 6192{
6269 deliver_process_signal (sig, handle_child_signal); 6193 deliver_process_signal (sig, handle_child_signal);
6270} 6194}
6271
6272#endif /* SIGCHLD */
6273 6195
6274 6196
6275static Lisp_Object 6197static Lisp_Object
@@ -7118,7 +7040,6 @@ init_process_emacs (void)
7118 7040
7119 inhibit_sentinels = 0; 7041 inhibit_sentinels = 0;
7120 7042
7121#ifdef SIGCHLD
7122#ifndef CANNOT_DUMP 7043#ifndef CANNOT_DUMP
7123 if (! noninteractive || initialized) 7044 if (! noninteractive || initialized)
7124#endif 7045#endif
@@ -7127,7 +7048,6 @@ init_process_emacs (void)
7127 emacs_sigaction_init (&action, deliver_child_signal); 7048 emacs_sigaction_init (&action, deliver_child_signal);
7128 sigaction (SIGCHLD, &action, 0); 7049 sigaction (SIGCHLD, &action, 0);
7129 } 7050 }
7130#endif
7131 7051
7132 FD_ZERO (&input_wait_mask); 7052 FD_ZERO (&input_wait_mask);
7133 FD_ZERO (&non_keyboard_wait_mask); 7053 FD_ZERO (&non_keyboard_wait_mask);
@@ -7154,9 +7074,7 @@ init_process_emacs (void)
7154#endif 7074#endif
7155 7075
7156 Vprocess_alist = Qnil; 7076 Vprocess_alist = Qnil;
7157#ifdef SIGCHLD
7158 deleted_pid_list = Qnil; 7077 deleted_pid_list = Qnil;
7159#endif
7160 for (i = 0; i < MAXDESC; i++) 7078 for (i = 0; i < MAXDESC; i++)
7161 { 7079 {
7162 chan_process[i] = Qnil; 7080 chan_process[i] = Qnil;
@@ -7283,9 +7201,7 @@ syms_of_process (void)
7283 DEFSYM (Qlast_nonmenu_event, "last-nonmenu-event"); 7201 DEFSYM (Qlast_nonmenu_event, "last-nonmenu-event");
7284 7202
7285 staticpro (&Vprocess_alist); 7203 staticpro (&Vprocess_alist);
7286#ifdef SIGCHLD
7287 staticpro (&deleted_pid_list); 7204 staticpro (&deleted_pid_list);
7288#endif
7289 7205
7290#endif /* subprocesses */ 7206#endif /* subprocesses */
7291 7207
diff --git a/src/sysdep.c b/src/sysdep.c
index 9c904850401..5291c5d59aa 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -457,20 +457,15 @@ static void restore_signal_handlers (struct save_signal *);
457void 457void
458sys_suspend (void) 458sys_suspend (void)
459{ 459{
460#if defined (SIGTSTP) && !defined (MSDOS) 460#ifndef DOS_NT
461 461 kill (0, SIGTSTP);
462 { 462#else
463 pid_t pgrp = getpgrp ();
464 EMACS_KILLPG (pgrp, SIGTSTP);
465 }
466
467#else /* No SIGTSTP */
468/* On a system where suspending is not implemented, 463/* On a system where suspending is not implemented,
469 instead fork a subshell and let it talk directly to the terminal 464 instead fork a subshell and let it talk directly to the terminal
470 while we wait. */ 465 while we wait. */
471 sys_subshell (); 466 sys_subshell ();
472 467
473#endif /* no SIGTSTP */ 468#endif
474} 469}
475 470
476/* Fork a subshell. */ 471/* Fork a subshell. */
@@ -1518,9 +1513,7 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1518 /* When handling a signal, block nonfatal system signals that are caught 1513 /* When handling a signal, block nonfatal system signals that are caught
1519 by Emacs. This makes race conditions less likely. */ 1514 by Emacs. This makes race conditions less likely. */
1520 sigaddset (&action->sa_mask, SIGALRM); 1515 sigaddset (&action->sa_mask, SIGALRM);
1521#ifdef SIGCHLD
1522 sigaddset (&action->sa_mask, SIGCHLD); 1516 sigaddset (&action->sa_mask, SIGCHLD);
1523#endif
1524#ifdef SIGDANGER 1517#ifdef SIGDANGER
1525 sigaddset (&action->sa_mask, SIGDANGER); 1518 sigaddset (&action->sa_mask, SIGDANGER);
1526#endif 1519#endif
@@ -1700,18 +1693,11 @@ init_signals (bool dumping)
1700# ifdef SIGAIO 1693# ifdef SIGAIO
1701 sys_siglist[SIGAIO] = "LAN I/O interrupt"; 1694 sys_siglist[SIGAIO] = "LAN I/O interrupt";
1702# endif 1695# endif
1703# ifdef SIGALRM
1704 sys_siglist[SIGALRM] = "Alarm clock"; 1696 sys_siglist[SIGALRM] = "Alarm clock";
1705# endif
1706# ifdef SIGBUS 1697# ifdef SIGBUS
1707 sys_siglist[SIGBUS] = "Bus error"; 1698 sys_siglist[SIGBUS] = "Bus error";
1708# endif 1699# endif
1709# ifdef SIGCLD
1710 sys_siglist[SIGCLD] = "Child status changed";
1711# endif
1712# ifdef SIGCHLD
1713 sys_siglist[SIGCHLD] = "Child status changed"; 1700 sys_siglist[SIGCHLD] = "Child status changed";
1714# endif
1715# ifdef SIGCONT 1701# ifdef SIGCONT
1716 sys_siglist[SIGCONT] = "Continued"; 1702 sys_siglist[SIGCONT] = "Continued";
1717# endif 1703# endif
@@ -1731,9 +1717,7 @@ init_signals (bool dumping)
1731# ifdef SIGGRANT 1717# ifdef SIGGRANT
1732 sys_siglist[SIGGRANT] = "Monitor mode granted"; 1718 sys_siglist[SIGGRANT] = "Monitor mode granted";
1733# endif 1719# endif
1734# ifdef SIGHUP
1735 sys_siglist[SIGHUP] = "Hangup"; 1720 sys_siglist[SIGHUP] = "Hangup";
1736# endif
1737 sys_siglist[SIGILL] = "Illegal instruction"; 1721 sys_siglist[SIGILL] = "Illegal instruction";
1738 sys_siglist[SIGINT] = "Interrupt"; 1722 sys_siglist[SIGINT] = "Interrupt";
1739# ifdef SIGIO 1723# ifdef SIGIO
@@ -1745,9 +1729,7 @@ init_signals (bool dumping)
1745# ifdef SIGIOT 1729# ifdef SIGIOT
1746 sys_siglist[SIGIOT] = "IOT trap"; 1730 sys_siglist[SIGIOT] = "IOT trap";
1747# endif 1731# endif
1748# ifdef SIGKILL
1749 sys_siglist[SIGKILL] = "Killed"; 1732 sys_siglist[SIGKILL] = "Killed";
1750# endif
1751# ifdef SIGLOST 1733# ifdef SIGLOST
1752 sys_siglist[SIGLOST] = "Resource lost"; 1734 sys_siglist[SIGLOST] = "Resource lost";
1753# endif 1735# endif
@@ -1760,9 +1742,7 @@ init_signals (bool dumping)
1760# ifdef SIGPHONE 1742# ifdef SIGPHONE
1761 sys_siglist[SIGWIND] = "SIGPHONE"; 1743 sys_siglist[SIGWIND] = "SIGPHONE";
1762# endif 1744# endif
1763# ifdef SIGPIPE
1764 sys_siglist[SIGPIPE] = "Broken pipe"; 1745 sys_siglist[SIGPIPE] = "Broken pipe";
1765# endif
1766# ifdef SIGPOLL 1746# ifdef SIGPOLL
1767 sys_siglist[SIGPOLL] = "Pollable event occurred"; 1747 sys_siglist[SIGPOLL] = "Pollable event occurred";
1768# endif 1748# endif
@@ -1775,9 +1755,7 @@ init_signals (bool dumping)
1775# ifdef SIGPWR 1755# ifdef SIGPWR
1776 sys_siglist[SIGPWR] = "Power-fail restart"; 1756 sys_siglist[SIGPWR] = "Power-fail restart";
1777# endif 1757# endif
1778# ifdef SIGQUIT
1779 sys_siglist[SIGQUIT] = "Quit"; 1758 sys_siglist[SIGQUIT] = "Quit";
1780# endif
1781# ifdef SIGRETRACT 1759# ifdef SIGRETRACT
1782 sys_siglist[SIGRETRACT] = "Need to relinquish monitor mode"; 1760 sys_siglist[SIGRETRACT] = "Need to relinquish monitor mode";
1783# endif 1761# endif
diff --git a/src/syssignal.h b/src/syssignal.h
index 2bf2f046aa5..8f9b5f0546a 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -54,26 +54,6 @@ char const *safe_strsignal (int) ATTRIBUTE_CONST;
54# define emacs_raise(sig) raise (sig) 54# define emacs_raise(sig) raise (sig)
55#endif 55#endif
56 56
57/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
58 Must do that using the killpg call. */
59#ifdef BSD_SYSTEM
60#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
61#else
62#ifdef WINDOWSNT
63#define EMACS_KILLPG(gid, signo) (kill (gid, signo))
64#else
65#define EMACS_KILLPG(gid, signo) (kill (-(gid), (signo)))
66#endif
67#endif
68
69/* Define SIGCHLD as an alias for SIGCLD. There are many conditionals
70 testing SIGCHLD. */
71#ifdef SIGCLD
72#ifndef SIGCHLD
73#define SIGCHLD SIGCLD
74#endif /* SIGCHLD */
75#endif /* ! defined (SIGCLD) */
76
77#ifndef HAVE_STRSIGNAL 57#ifndef HAVE_STRSIGNAL
78# define strsignal(sig) safe_strsignal (sig) 58# define strsignal(sig) safe_strsignal (sig)
79#endif 59#endif
diff --git a/src/w32proc.c b/src/w32proc.c
index 0b36804b0e8..d888200c556 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -2122,6 +2122,10 @@ sys_kill (int pid, int sig)
2122 int need_to_free = 0; 2122 int need_to_free = 0;
2123 int rc = 0; 2123 int rc = 0;
2124 2124
2125 /* Each process is in its own process group. */
2126 if (pid < 0)
2127 pid = -pid;
2128
2125 /* Only handle signals that will result in the process dying */ 2129 /* Only handle signals that will result in the process dying */
2126 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP) 2130 if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
2127 { 2131 {