unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
@ 2012-11-29  6:52 Paul Eggert
  2012-11-29 17:33 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2012-11-29  6:52 UTC (permalink / raw)
  To: 13026

Tags: patch

Attached is a proposed patch to simplify Emacs by assuming
POSIX 1003.1-1988 or later for signal.h, which I'd
like to install soon.  This patch is relative to
trunk bzr 111026.  Tested on Fedora 17.

=== modified file 'ChangeLog'
--- ChangeLog	2012-11-27 03:10:32 +0000
+++ ChangeLog	2012-11-29 06:46:35 +0000
@@ -1,3 +1,9 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h.
+	* configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF):
+	Use SIGCHLD rather than SIGCLD.
+
 2012-11-27  Eli Zaretskii  <eliz@gnu.org>
 
 	* make-dist (nt): Adjust to changes in names of the *.manifest files.

=== modified file 'admin/CPP-DEFINES'
--- admin/CPP-DEFINES	2012-11-24 17:20:49 +0000
+++ admin/CPP-DEFINES	2012-11-29 06:46:35 +0000
@@ -419,14 +419,7 @@
 PURESIZE
 RUN_TIME_REMAP
 SETUP_SLAVE_PTY
-SIGALRM
-SIGCHLD
-SIGHUP
-SIGKILL
 SIGNALS_VIA_CHARACTERS
-SIGPIPE
-SIGQUIT
-SIGTRAP
 STDC_HEADERS
 SYSTEM_PURESIZE_EXTRA
 SYSTEM_MALLOC

=== modified file 'admin/ChangeLog'
--- admin/ChangeLog	2012-11-24 17:20:49 +0000
+++ admin/ChangeLog	2012-11-29 06:46:35 +0000
@@ -1,3 +1,10 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h.
+	* CPP-DEFINES (SIGALRM, SIGCHLD, SIGHUP, SIGKILL, SIGPIPE, SIGQUIT):
+	Remove.
+	(SIGTRAP): Remove this one too, as config.h no longer defines it.
+
 2012-11-24  Ken Brown  <kbrown@cornell.edu>
 
 	* CPP-DEFINES (HAVE_MOUSE): Remove.

=== modified file 'configure.ac'
--- configure.ac	2012-11-27 03:10:32 +0000
+++ configure.ac	2012-11-29 06:46:35 +0000
@@ -3600,7 +3600,7 @@
     AC_DEFINE(PTY_ITERATION, [])
     dnl Not used, because PTY_ITERATION is defined.
     AC_DEFINE(FIRST_PTY_LETTER, ['q'])
-    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
+    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
     dnl No need to get the pty name at all.
     AC_DEFINE(PTY_NAME_SPRINTF, [])
     dnl No need to use sprintf to get the tty name--we get that from _getpty.
@@ -3611,12 +3611,12 @@
     dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
     dnl from intercepting that death.  If any child but grantpt's should die
     dnl within, it should be caught after sigrelse(2).
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 
   unixware )
     dnl Comments are as per sol2*.
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 esac
 

=== modified file 'lib-src/ChangeLog'
--- lib-src/ChangeLog	2012-11-27 05:17:07 +0000
+++ lib-src/ChangeLog	2012-11-29 06:46:35 +0000
@@ -1,3 +1,8 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h.
+	* emacsclient.c (main): Assume SIGSTOP is defined.
+
 2012-11-27  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Assume POSIX 1003.1-1988 or later for errno.h (Bug#12968).

=== modified file 'lib-src/emacsclient.c'
--- lib-src/emacsclient.c	2012-11-21 21:06:52 +0000
+++ lib-src/emacsclient.c	2012-11-29 06:46:35 +0000
@@ -1801,7 +1801,6 @@
               needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
               exit_status = EXIT_FAILURE;
             }
-#ifdef SIGSTOP
 	  else if (strprefix ("-suspend ", p))
 	    {
 	      /* -suspend: Suspend this terminal, i.e., stop the process. */
@@ -1810,7 +1809,6 @@
 	      needlf = 0;
 	      kill (0, SIGSTOP);
 	    }
-#endif
 	  else
 	    {
 	      /* Unknown command. */

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-11-29 06:00:21 +0000
+++ src/ChangeLog	2012-11-29 06:47:50 +0000
@@ -1,3 +1,30 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h.
+	* keyboard.c (stuff_buffered_input, handle_interrupt):
+	Assume SIGTSTP is defined.
+	* process.c (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.
+	(process_send_signal, Fcontinue_process): Assume SIGCONT is defined.
+	(Fstop_process): Assume SIGTSTP is defined.
+	(Fsignal_process): Assume SIGUSR1, SIGUSR2, SIGHUP, SIGQUIT,
+	SIGKILL, SIGPIPE, SIGALRM, SIGSTOP, SIGTSTP, SIGCONT, SIGCHLD,
+	SIGTTIN and SIGTTOU are defined.
+	* sysdep.c (stuff_char, sys_suspend): Assume SIGTSTP is defined.
+	(sys_suspend) [!MSDOS]: Use kill (0, ...) rather than
+	kill (getpgrp (), ...).
+	(tcsetpgrp_without_stopping): Assume SIGTTOU is defined.
+	(emacs_sigaction_init): Assume SIGCHLD is defined.
+	(init_signals): Assume SIGALRM, SIGCHLD, SIGCONT, SIGHUP, SIGKILL,
+	SIGPIPE, SIGQUIT, SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU, SIGUSR1 and
+	SIGUSR2 are defined.  Do not worry about SIGCLD any more.
+	* syssignal.h (EMACS_KILLPG): Remove.  All uses replaced by 'kill'
+	with a negative pid.
+	(SIGCHLD): Remove definition, as we now assume SIGCHLD.
+	* w32proc.c (sys_kill): Support negative pids compatibly with POSIX.
+
 2012-11-29  Dmitry Antipov  <dmantipov@yandex.ru>
 
 	* xdisp.c (window_outdated): Remove eassert since it hits

=== modified file 'src/callproc.c'
--- src/callproc.c	2012-11-29 00:36:22 +0000
+++ src/callproc.c	2012-11-29 06:46:35 +0000
@@ -97,7 +97,7 @@
   CONS_TO_INTEGER (Fcar (fdpid), int, fd);
   CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
   emacs_close (fd);
-  EMACS_KILLPG (pid, SIGKILL);
+  kill (-pid, SIGKILL);
   synch_process_alive = 0;
   return Qnil;
 }
@@ -134,7 +134,7 @@
       return Qnil;
     }
 
-  if (EMACS_KILLPG (pid, SIGINT) == 0)
+  if (kill (-pid, SIGINT) == 0)
     {
       ptrdiff_t count = SPECPDL_INDEX ();
       record_unwind_protect (call_process_kill, fdpid);

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2012-11-27 05:17:07 +0000
+++ src/keyboard.c	2012-11-29 06:46:35 +0000
@@ -10552,8 +10552,7 @@
 void
 stuff_buffered_input (Lisp_Object stuffstring)
 {
-#ifdef SIGTSTP  /* stuff_char is defined if SIGTSTP.  */
-  register unsigned char *p;
+  unsigned char *p;
 
   if (STRINGP (stuffstring))
     {
@@ -10584,7 +10583,6 @@
     }
 
   input_pending = 0;
-#endif /* SIGTSTP */
 }
 \f
 void
@@ -10689,22 +10687,13 @@
       fflush (stdout);
       reset_all_sys_modes ();
 
-#ifdef SIGTSTP			/* Support possible in later USG versions */
 /*
- * On systems which can suspend the current process and return to the original
- * shell, this command causes the user to end up back at the shell.
+ * Cause the user to end up back at the shell.
  * The "Auto-save" and "Abort" questions are not asked until
  * the user elects to return to emacs, at which point he can save the current
  * job and either dump core or continue.
  */
       sys_suspend ();
-#else
-      /* Perhaps should really fork an inferior shell?
-	 But that would not provide any way to get back
-	 to the original shell, ever.  */
-      printf ("No support for stopping a process on this operating system;\n");
-      printf ("you can continue or abort.\n");
-#endif /* not SIGTSTP */
 #ifdef MSDOS
       /* We must remain inside the screen area when the internal terminal
 	 is used.  Note that [Enter] is not echoed by dos.  */

=== modified file 'src/process.c'
--- src/process.c	2012-11-27 05:17:07 +0000
+++ src/process.c	2012-11-29 06:46:35 +0000
@@ -773,13 +773,11 @@
 }
 
 
-#ifdef SIGCHLD
 /* Fdelete_process promises to immediately forget about the process, but in
    reality, Emacs needs to remember those processes until they have been
    treated by the SIGCHLD handler and waitpid has been invoked on them;
    otherwise they might fill up the kernel's process table.  */
 static Lisp_Object deleted_pid_list;
-#endif
 
 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
        doc: /* Delete PROCESS: kill it and forget about it immediately.
@@ -802,7 +800,6 @@
     }
   else if (p->infd >= 0)
     {
-#ifdef SIGCHLD
       Lisp_Object symbol;
       pid_t pid = p->pid;
 
@@ -820,7 +817,6 @@
 	deleted_pid_list
 	  = Fdelete (make_fixnum_or_float (pid), deleted_pid_list);
       else
-#endif
 	{
 	  Fkill_process (process, Qnil);
 	  /* Do this now, since remove_process will make the
@@ -1578,9 +1574,7 @@
 #ifndef WINDOWSNT
   int wait_child_setup[2];
 #endif
-#ifdef SIGCHLD
   sigset_t blocked;
-#endif
   /* Use volatile to protect variables from being clobbered by vfork.  */
   volatile int forkin, forkout;
   volatile int pty_flag = 0;
@@ -1680,13 +1674,11 @@
 
   block_input ();
 
-#ifdef SIGCHLD
   /* Block SIGCHLD until we have a chance to store the new fork's
      pid in its process structure.  */
   sigemptyset (&blocked);
   sigaddset (&blocked, SIGCHLD);
   pthread_sigmask (SIG_BLOCK, &blocked, 0);
-#endif
 
 #if HAVE_WORKING_VFORK
   /* child_setup must clobber environ on systems with true vfork.
@@ -1800,10 +1792,8 @@
       /* Emacs ignores SIGPIPE, but the child should not.  */
       signal (SIGPIPE, SIG_DFL);
 
-#ifdef SIGCHLD
 	/* Stop blocking signals in the child.  */
       pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
 
       if (pty_flag)
 	child_setup_tty (xforkout);
@@ -1828,9 +1818,7 @@
     XPROCESS (process)->alive = 1;
 
   /* Stop blocking signals in the parent.  */
-#ifdef SIGCHLD
   pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
   unblock_input ();
 
   if (pid < 0)
@@ -4622,7 +4610,7 @@
 		 yielding EBADF here or at select() call above.
 		 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
 		 in m/ibmrt-aix.h), and here we just ignore the select error.
-		 Cleanup occurs c/o status_notify after SIGCLD. */
+		 Cleanup occurs c/o status_notify after SIGCHLD. */
 	      no_avail = 1; /* Cannot depend on values returned */
 #else
 	      emacs_abort ();
@@ -4820,10 +4808,8 @@
 #endif /* HAVE_PTYS */
 	      /* If we can detect process termination, don't consider the
 		 process gone just because its pipe is closed.  */
-#ifdef SIGCHLD
 	      else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc))
 		;
-#endif
 	      else
 		{
 		  /* Preserve status of processes already terminated.  */
@@ -5686,7 +5672,7 @@
 
    If we can, we try to signal PROCESS by sending control characters
    down the pty.  This allows us to signal inferiors who have changed
-   their uid, for which killpg would return an EPERM error.  */
+   their uid, for which kill would return an EPERM error.  */
 
 static void
 process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
@@ -5791,7 +5777,6 @@
 
   switch (signo)
     {
-#ifdef SIGCONT
     case SIGCONT:
       p->raw_status_new = 0;
       pset_status (p, Qrun);
@@ -5802,7 +5787,7 @@
 	  redisplay_preserve_echo_area (13);
 	}
       break;
-#endif /* ! defined (SIGCONT) */
+
     case SIGINT:
     case SIGQUIT:
     case SIGKILL:
@@ -5824,7 +5809,7 @@
   if (!NILP (current_group))
     {
       if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
-	EMACS_KILLPG (gid, signo);
+	kill (-gid, signo);
     }
   else
     {
@@ -5832,7 +5817,7 @@
       kill (gid, signo);
     }
 #else /* ! defined (TIOCSIGSEND) */
-  EMACS_KILLPG (gid, signo);
+  kill (-gid, signo);
 #endif /* ! defined (TIOCSIGSEND) */
 }
 
@@ -5893,11 +5878,8 @@
       pset_command (p, Qt);
       return process;
     }
-#ifndef SIGTSTP
-  error ("No SIGTSTP support");
-#else
+
   process_send_signal (process, SIGTSTP, current_group, 0);
-#endif
   return process;
 }
 
@@ -5929,11 +5911,8 @@
       pset_command (p, Qnil);
       return process;
     }
-#ifdef SIGCONT
-    process_send_signal (process, SIGCONT, current_group, 0);
-#else
-    error ("No SIGCONT support");
-#endif
+
+  process_send_signal (process, SIGCONT, current_group, 0);
   return process;
 }
 
@@ -5994,28 +5973,18 @@
 
       if (0)
 	;
-#ifdef SIGUSR1
       parse_signal ("usr1", SIGUSR1);
-#endif
-#ifdef SIGUSR2
       parse_signal ("usr2", SIGUSR2);
-#endif
       parse_signal ("term", SIGTERM);
-#ifdef SIGHUP
       parse_signal ("hup", SIGHUP);
-#endif
       parse_signal ("int", SIGINT);
-#ifdef SIGQUIT
       parse_signal ("quit", SIGQUIT);
-#endif
       parse_signal ("ill", SIGILL);
       parse_signal ("abrt", SIGABRT);
 #ifdef SIGEMT
       parse_signal ("emt", SIGEMT);
 #endif
-#ifdef SIGKILL
       parse_signal ("kill", SIGKILL);
-#endif
       parse_signal ("fpe", SIGFPE);
 #ifdef SIGBUS
       parse_signal ("bus", SIGBUS);
@@ -6024,33 +5993,17 @@
 #ifdef SIGSYS
       parse_signal ("sys", SIGSYS);
 #endif
-#ifdef SIGPIPE
       parse_signal ("pipe", SIGPIPE);
-#endif
-#ifdef SIGALRM
       parse_signal ("alrm", SIGALRM);
-#endif
 #ifdef SIGURG
       parse_signal ("urg", SIGURG);
 #endif
-#ifdef SIGSTOP
       parse_signal ("stop", SIGSTOP);
-#endif
-#ifdef SIGTSTP
       parse_signal ("tstp", SIGTSTP);
-#endif
-#ifdef SIGCONT
       parse_signal ("cont", SIGCONT);
-#endif
-#ifdef SIGCHLD
       parse_signal ("chld", SIGCHLD);
-#endif
-#ifdef SIGTTIN
       parse_signal ("ttin", SIGTTIN);
-#endif
-#ifdef SIGTTOU
       parse_signal ("ttou", SIGTTOU);
-#endif
 #ifdef SIGIO
       parse_signal ("io", SIGIO);
 #endif
@@ -6214,7 +6167,6 @@
 void
 record_child_status_change (pid_t pid, int w)
 {
-#ifdef SIGCHLD
 
   /* Record at most one child only if we already know one child that
      has exited.  */
@@ -6303,11 +6255,8 @@
       if (input_available_clear_time)
 	*input_available_clear_time = make_emacs_time (0, 0);
     }
-#endif
 }
 
-#ifdef SIGCHLD
-
 static void
 handle_child_signal (int sig)
 {
@@ -6319,8 +6268,6 @@
 {
   deliver_process_signal (sig, handle_child_signal);
 }
-
-#endif /* SIGCHLD */
 \f
 
 static Lisp_Object
@@ -7169,7 +7116,6 @@
 
   inhibit_sentinels = 0;
 
-#ifdef SIGCHLD
 #ifndef CANNOT_DUMP
   if (! noninteractive || initialized)
 #endif
@@ -7178,7 +7124,6 @@
       emacs_sigaction_init (&action, deliver_child_signal);
       sigaction (SIGCHLD, &action, 0);
     }
-#endif
 
   FD_ZERO (&input_wait_mask);
   FD_ZERO (&non_keyboard_wait_mask);
@@ -7205,9 +7150,7 @@
 #endif
 
   Vprocess_alist = Qnil;
-#ifdef SIGCHLD
   deleted_pid_list = Qnil;
-#endif
   for (i = 0; i < MAXDESC; i++)
     {
       chan_process[i] = Qnil;
@@ -7334,9 +7277,7 @@
   DEFSYM (Qlast_nonmenu_event, "last-nonmenu-event");
 
   staticpro (&Vprocess_alist);
-#ifdef SIGCHLD
   staticpro (&deleted_pid_list);
-#endif
 
 #endif	/* subprocesses */
 

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2012-11-27 03:10:32 +0000
+++ src/sysdep.c	2012-11-29 06:46:35 +0000
@@ -213,8 +213,6 @@
 }
 
 \f
-#ifdef SIGTSTP
-
 /* Arrange for character C to be read as the next input from
    the terminal.
    XXX What if we have multiple ttys?
@@ -233,8 +231,6 @@
   error ("Cannot stuff terminal input characters in this version of Unix");
 #endif /* no TIOCSTI */
 }
-
-#endif /* SIGTSTP */
 \f
 void
 init_baud_rate (int fd)
@@ -428,20 +424,15 @@
 void
 sys_suspend (void)
 {
-#if defined (SIGTSTP) && !defined (MSDOS)
-
-  {
-    pid_t pgrp = getpgrp ();
-    EMACS_KILLPG (pgrp, SIGTSTP);
-  }
-
-#else /* No SIGTSTP */
+#ifndef MSDOS
+  kill (0, SIGTSTP);
+#else
 /* On a system where suspending is not implemented,
    instead fork a subshell and let it talk directly to the terminal
    while we wait.  */
   sys_subshell ();
 
-#endif /* no SIGTSTP */
+#endif
 }
 
 /* Fork a subshell.  */
@@ -702,14 +693,12 @@
 static void
 tcsetpgrp_without_stopping (int fd, pid_t pgid)
 {
-#ifdef SIGTTOU
   signal_handler_t handler;
   block_input ();
   handler = signal (SIGTTOU, SIG_IGN);
   tcsetpgrp (fd, pgid);
   signal (SIGTTOU, handler);
   unblock_input ();
-#endif
 }
 
 /* Split off the foreground process group to Emacs alone.  When we are
@@ -1491,9 +1480,7 @@
   /* When handling a signal, block nonfatal system signals that are caught
      by Emacs.  This makes race conditions less likely.  */
   sigaddset (&action->sa_mask, SIGALRM);
-#ifdef SIGCHLD
   sigaddset (&action->sa_mask, SIGCHLD);
-#endif
 #ifdef SIGDANGER
   sigaddset (&action->sa_mask, SIGDANGER);
 #endif
@@ -1673,21 +1660,12 @@
 # ifdef SIGAIO
       sys_siglist[SIGAIO] = "LAN I/O interrupt";
 # endif
-# ifdef SIGALRM
       sys_siglist[SIGALRM] = "Alarm clock";
-# endif
 # ifdef SIGBUS
       sys_siglist[SIGBUS] = "Bus error";
 # endif
-# ifdef SIGCLD
-      sys_siglist[SIGCLD] = "Child status changed";
-# endif
-# ifdef SIGCHLD
       sys_siglist[SIGCHLD] = "Child status changed";
-# endif
-# ifdef SIGCONT
       sys_siglist[SIGCONT] = "Continued";
-# endif
 # ifdef SIGDANGER
       sys_siglist[SIGDANGER] = "Swap space dangerously low";
 # endif
@@ -1704,9 +1682,7 @@
 # ifdef SIGGRANT
       sys_siglist[SIGGRANT] = "Monitor mode granted";
 # endif
-# ifdef SIGHUP
       sys_siglist[SIGHUP] = "Hangup";
-# endif
       sys_siglist[SIGILL] = "Illegal instruction";
       sys_siglist[SIGINT] = "Interrupt";
 # ifdef SIGIO
@@ -1718,9 +1694,7 @@
 # ifdef SIGIOT
       sys_siglist[SIGIOT] = "IOT trap";
 # endif
-# ifdef SIGKILL
       sys_siglist[SIGKILL] = "Killed";
-# endif
 # ifdef SIGLOST
       sys_siglist[SIGLOST] = "Resource lost";
 # endif
@@ -1733,9 +1707,7 @@
 # ifdef SIGPHONE
       sys_siglist[SIGWIND] = "SIGPHONE";
 # endif
-# ifdef SIGPIPE
       sys_siglist[SIGPIPE] = "Broken pipe";
-# endif
 # ifdef SIGPOLL
       sys_siglist[SIGPOLL] = "Pollable event occurred";
 # endif
@@ -1748,9 +1720,7 @@
 # ifdef SIGPWR
       sys_siglist[SIGPWR] = "Power-fail restart";
 # endif
-# ifdef SIGQUIT
       sys_siglist[SIGQUIT] = "Quit";
-# endif
 # ifdef SIGRETRACT
       sys_siglist[SIGRETRACT] = "Need to relinquish monitor mode";
 # endif
@@ -1761,9 +1731,7 @@
 # ifdef SIGSOUND
       sys_siglist[SIGSOUND] = "Sound completed";
 # endif
-# ifdef SIGSTOP
       sys_siglist[SIGSTOP] = "Stopped (signal)";
-# endif
 # ifdef SIGSTP
       sys_siglist[SIGSTP] = "Stopped (user)";
 # endif
@@ -1777,24 +1745,14 @@
 # ifdef SIGTRAP
       sys_siglist[SIGTRAP] = "Trace/breakpoint trap";
 # endif
-# ifdef SIGTSTP
       sys_siglist[SIGTSTP] = "Stopped (user)";
-# endif
-# ifdef SIGTTIN
       sys_siglist[SIGTTIN] = "Stopped (tty input)";
-# endif
-# ifdef SIGTTOU
       sys_siglist[SIGTTOU] = "Stopped (tty output)";
-# endif
 # ifdef SIGURG
       sys_siglist[SIGURG] = "Urgent I/O condition";
 # endif
-# ifdef SIGUSR1
       sys_siglist[SIGUSR1] = "User defined signal 1";
-# endif
-# ifdef SIGUSR2
       sys_siglist[SIGUSR2] = "User defined signal 2";
-# endif
 # ifdef SIGVTALRM
       sys_siglist[SIGVTALRM] = "Virtual timer expired";
 # endif
@@ -1861,12 +1819,8 @@
       sigaction (SIGFPE, &action, 0);
     }
 
-#ifdef SIGUSR1
   add_user_signal (SIGUSR1, "sigusr1");
-#endif
-#ifdef SIGUSR2
   add_user_signal (SIGUSR2, "sigusr2");
-#endif
   sigaction (SIGABRT, &thread_fatal_action, 0);
 #ifdef SIGPRE
   sigaction (SIGPRE, &thread_fatal_action, 0);

=== modified file 'src/syssignal.h'
--- src/syssignal.h	2012-10-07 02:26:03 +0000
+++ src/syssignal.h	2012-11-29 06:46:35 +0000
@@ -54,26 +54,6 @@
 # define emacs_raise(sig) raise (sig)
 #endif
 
-/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
-   Must do that using the killpg call.  */
-#ifdef BSD_SYSTEM
-#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
-#else
-#ifdef WINDOWSNT
-#define EMACS_KILLPG(gid, signo) (kill (gid, signo))
-#else
-#define EMACS_KILLPG(gid, signo) (kill   (-(gid), (signo)))
-#endif
-#endif
-
-/* Define SIGCHLD as an alias for SIGCLD.  There are many conditionals
-   testing SIGCHLD.  */
-#ifdef SIGCLD
-#ifndef SIGCHLD
-#define SIGCHLD SIGCLD
-#endif /* SIGCHLD */
-#endif /* ! defined (SIGCLD) */
-
 #ifndef HAVE_STRSIGNAL
 # define strsignal(sig) safe_strsignal (sig)
 #endif

=== modified file 'src/w32proc.c'
--- src/w32proc.c	2012-11-27 03:10:32 +0000
+++ src/w32proc.c	2012-11-29 06:46:35 +0000
@@ -2139,6 +2139,10 @@
   int need_to_free = 0;
   int rc = 0;
 
+  /* Each process is in its own process group.  */
+  if (pid < 0)
+    pid = -pid;
+
   /* Only handle signals that will result in the process dying */
   if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
     {






^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-11-29  6:52 bug#13026: Assume POSIX 1003.1-1988 or later for signal.h Paul Eggert
@ 2012-11-29 17:33 ` Eli Zaretskii
  2012-11-29 21:38   ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2012-11-29 17:33 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 13026

> Date: Wed, 28 Nov 2012 22:52:31 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> 
> Attached is a proposed patch to simplify Emacs by assuming
> POSIX 1003.1-1988 or later for signal.h, which I'd
> like to install soon.  This patch is relative to
> trunk bzr 111026.  Tested on Fedora 17.

This will break the Windows build in more than one way, unless
accompanied by suitable Windows-only changes.  Is this the entire
changeset, or did you omit some more changes?

Here are the problems I found:

> === modified file 'lib-src/emacsclient.c'
> --- lib-src/emacsclient.c	2012-11-21 21:06:52 +0000
> +++ lib-src/emacsclient.c	2012-11-29 06:46:35 +0000
> @@ -1801,7 +1801,6 @@
>                needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
>                exit_status = EXIT_FAILURE;
>              }
> -#ifdef SIGSTOP
>  	  else if (strprefix ("-suspend ", p))
>  	    {
>  	      /* -suspend: Suspend this terminal, i.e., stop the process. */
> @@ -1810,7 +1809,6 @@
>  	      needlf = 0;
>  	      kill (0, SIGSTOP);
>  	    }
> -#endif
>  	  else
>  	    {
>  	      /* Unknown command. */

This will break compilation of emacsclient.c, because SIGSTOP is not
defined on MS-Windows, and therefore the -suspend option cannot be
supported.  And even if we define SIGSTOP to some value, having
"-suspend" pretend to work, but do nothing is not a good idea.  (We
could emulate this option, but that would be a non-trivial change,
certainly not belonging in this changeset.)

Also, there's no 'kill' on Windows, and the emulation in w32proc.c is
only compiled into Emacs itself, not into lib-src programs.

> --- src/keyboard.c	2012-11-27 05:17:07 +0000
> +++ src/keyboard.c	2012-11-29 06:46:35 +0000
> @@ -10552,8 +10552,7 @@
>  void
>  stuff_buffered_input (Lisp_Object stuffstring)
>  {
> -#ifdef SIGTSTP  /* stuff_char is defined if SIGTSTP.  */
> -  register unsigned char *p;
> +  unsigned char *p;
>  
>    if (STRINGP (stuffstring))
>      {
> @@ -10584,7 +10583,6 @@
>      }
>  
>    input_pending = 0;
> -#endif /* SIGTSTP */
>  }

This will break suspend-emacs on MS-Windows (which does work now by
launching a sub-shell), because stuff_char, called by
stuff_buffered_input, will now signal an error.

> -#ifdef SIGTSTP			/* Support possible in later USG versions */
>  /*
> - * On systems which can suspend the current process and return to the original
> - * shell, this command causes the user to end up back at the shell.
> + * Cause the user to end up back at the shell.
>   * The "Auto-save" and "Abort" questions are not asked until
>   * the user elects to return to emacs, at which point he can save the current
>   * job and either dump core or continue.
>   */
>        sys_suspend ();
> -#else
> -      /* Perhaps should really fork an inferior shell?
> -	 But that would not provide any way to get back
> -	 to the original shell, ever.  */
> -      printf ("No support for stopping a process on this operating system;\n");
> -      printf ("you can continue or abort.\n");
> -#endif /* not SIGTSTP */
>  #ifdef MSDOS
>        /* We must remain inside the screen area when the internal terminal
>  	 is used.  Note that [Enter] is not echoed by dos.  */

This will also break Windows, because it cannot_suspend, so calling
sys_suspend for it does nothing useful (the Windows 'kill' emulation
only works on processes other than Emacs, and again SIGTSTP is not
going to suspend anything).

> @@ -5791,7 +5777,6 @@
>  
>    switch (signo)
>      {
> -#ifdef SIGCONT
>      case SIGCONT:
>        p->raw_status_new = 0;
>        pset_status (p, Qrun);
> @@ -5802,7 +5787,7 @@
>  	  redisplay_preserve_echo_area (13);
>  	}
>        break;
> -#endif /* ! defined (SIGCONT) */

This won't compile, since SIGCONT is not defined on Windows.

> @@ -5929,11 +5911,8 @@
>        pset_command (p, Qnil);
>        return process;
>      }
> -#ifdef SIGCONT
> -    process_send_signal (process, SIGCONT, current_group, 0);
> -#else
> -    error ("No SIGCONT support");
> -#endif
> +
> +  process_send_signal (process, SIGCONT, current_group, 0);
>    return process;
>  }

Likewise.

> @@ -5994,28 +5973,18 @@
>  
>        if (0)
>  	;
> -#ifdef SIGUSR1
>        parse_signal ("usr1", SIGUSR1);
> -#endif
> -#ifdef SIGUSR2
>        parse_signal ("usr2", SIGUSR2);
> -#endif

Likewise: SIGUSR1 and SIGUSR2 are not defined.

> -#ifdef SIGSTOP
>        parse_signal ("stop", SIGSTOP);
> -#endif
> -#ifdef SIGTSTP
>        parse_signal ("tstp", SIGTSTP);
> -#endif
> -#ifdef SIGCONT
>        parse_signal ("cont", SIGCONT);
> -#endif
> -#ifdef SIGCHLD
>        parse_signal ("chld", SIGCHLD);
> -#endif
> -#ifdef SIGTTIN
>        parse_signal ("ttin", SIGTTIN);
> -#endif
> -#ifdef SIGTTOU
>        parse_signal ("ttou", SIGTTOU);
> -#endif

And the same for all these, except SIGCHLD.

> --- src/sysdep.c	2012-11-27 03:10:32 +0000
> +++ src/sysdep.c	2012-11-29 06:46:35 +0000
> @@ -213,8 +213,6 @@
>  }
>  
>  \f
> -#ifdef SIGTSTP
> -
>  /* Arrange for character C to be read as the next input from
>     the terminal.
>     XXX What if we have multiple ttys?
> @@ -233,8 +231,6 @@
>    error ("Cannot stuff terminal input characters in this version of Unix");
>  #endif /* no TIOCSTI */
>  }
> -
> -#endif /* SIGTSTP */

See above: this will now signal an error on Windows.

> @@ -428,20 +424,15 @@
>  void
>  sys_suspend (void)
>  {
> -#if defined (SIGTSTP) && !defined (MSDOS)
> -
> -  {
> -    pid_t pgrp = getpgrp ();
> -    EMACS_KILLPG (pgrp, SIGTSTP);
> -  }
> -
> -#else /* No SIGTSTP */
> +#ifndef MSDOS
> +  kill (0, SIGTSTP);
> +#else
>  /* On a system where suspending is not implemented,
>     instead fork a subshell and let it talk directly to the terminal
>     while we wait.  */
>    sys_subshell ();
>  
> -#endif /* no SIGTSTP */
> +#endif
>  }

Windows should also call sys_subshell here.

> @@ -702,14 +693,12 @@
>  static void
>  tcsetpgrp_without_stopping (int fd, pid_t pgid)
>  {
> -#ifdef SIGTTOU
>    signal_handler_t handler;
>    block_input ();
>    handler = signal (SIGTTOU, SIG_IGN);
>    tcsetpgrp (fd, pgid);
>    signal (SIGTTOU, handler);
>    unblock_input ();
> -#endif
>  }

This won't compile because SIGTTOU is not defined.  Also, there's no
tcsetpgrp on Windows, so this won't link unless we provide an
emulation.

> -# ifdef SIGCONT
>        sys_siglist[SIGCONT] = "Continued";
> -# endif

Won't compile.

> -# ifdef SIGSTOP
>        sys_siglist[SIGSTOP] = "Stopped (signal)";
> -# endif

Likewise.

> -# ifdef SIGTSTP
>        sys_siglist[SIGTSTP] = "Stopped (user)";
> -# endif
> -# ifdef SIGTTIN
>        sys_siglist[SIGTTIN] = "Stopped (tty input)";
> -# endif
> -# ifdef SIGTTOU
>        sys_siglist[SIGTTOU] = "Stopped (tty output)";
> -# endif

Likewise.

> -# ifdef SIGUSR1
>        sys_siglist[SIGUSR1] = "User defined signal 1";
> -# endif
> -# ifdef SIGUSR2
>        sys_siglist[SIGUSR2] = "User defined signal 2";
> -# endif

Likewise.

Please also note that NSIG is 23 on Windows, so the sys_siglist array
cannot be much larger than it already is (I think most of the 23 slots
are already used up).

> @@ -1861,12 +1819,8 @@
>        sigaction (SIGFPE, &action, 0);
>      }
>  
> -#ifdef SIGUSR1
>    add_user_signal (SIGUSR1, "sigusr1");
> -#endif
> -#ifdef SIGUSR2
>    add_user_signal (SIGUSR2, "sigusr2");
> -#endif

Won't compile.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-11-29 17:33 ` Eli Zaretskii
@ 2012-11-29 21:38   ` Paul Eggert
  2012-11-30  8:54     ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2012-11-29 21:38 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13026

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

On 11/29/12 09:33, Eli Zaretskii wrote:

> This will break the Windows build in more than one way, unless
> accompanied by suitable Windows-only changes.  Is this the entire
> changeset, or did you omit some more changes?

That was the entire changeset.  I didn't know about the problems
on MS-Windows.  I trimmed down the patch, to avoid the issues you
raised, and am attaching a proposed revised patch.  Thanks for
the review.


[-- Attachment #2: signal.txt --]
[-- Type: text/plain, Size: 16950 bytes --]

=== modified file 'ChangeLog'
--- ChangeLog	2012-11-27 03:10:32 +0000
+++ ChangeLog	2012-11-29 06:55:02 +0000
@@ -1,3 +1,9 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	* configure.ac (PTY_OPEN, PTY_TTY_NAME_SPRINTF):
+	Use SIGCHLD rather than SIGCLD.
+
 2012-11-27  Eli Zaretskii  <eliz@gnu.org>
 
 	* make-dist (nt): Adjust to changes in names of the *.manifest files.

=== modified file 'admin/CPP-DEFINES'
--- admin/CPP-DEFINES	2012-11-24 17:20:49 +0000
+++ admin/CPP-DEFINES	2012-11-29 06:46:35 +0000
@@ -419,14 +419,7 @@
 PURESIZE
 RUN_TIME_REMAP
 SETUP_SLAVE_PTY
-SIGALRM
-SIGCHLD
-SIGHUP
-SIGKILL
 SIGNALS_VIA_CHARACTERS
-SIGPIPE
-SIGQUIT
-SIGTRAP
 STDC_HEADERS
 SYSTEM_PURESIZE_EXTRA
 SYSTEM_MALLOC

=== modified file 'admin/ChangeLog'
--- admin/ChangeLog	2012-11-24 17:20:49 +0000
+++ admin/ChangeLog	2012-11-29 06:55:02 +0000
@@ -1,3 +1,10 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	* CPP-DEFINES (SIGALRM, SIGCHLD, SIGHUP, SIGKILL, SIGPIPE, SIGQUIT):
+	Remove.
+	(SIGTRAP): Remove this one too, as config.h no longer defines it.
+
 2012-11-24  Ken Brown  <kbrown@cornell.edu>
 
 	* CPP-DEFINES (HAVE_MOUSE): Remove.

=== modified file 'configure.ac'
--- configure.ac	2012-11-27 03:10:32 +0000
+++ configure.ac	2012-11-29 06:46:35 +0000
@@ -3600,7 +3600,7 @@
     AC_DEFINE(PTY_ITERATION, [])
     dnl Not used, because PTY_ITERATION is defined.
     AC_DEFINE(FIRST_PTY_LETTER, ['q'])
-    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
+    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
     dnl No need to get the pty name at all.
     AC_DEFINE(PTY_NAME_SPRINTF, [])
     dnl No need to use sprintf to get the tty name--we get that from _getpty.
@@ -3611,12 +3611,12 @@
     dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
     dnl from intercepting that death.  If any child but grantpt's should die
     dnl within, it should be caught after sigrelse(2).
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 
   unixware )
     dnl Comments are as per sol2*.
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 esac
 

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-11-29 06:00:21 +0000
+++ src/ChangeLog	2012-11-29 21:33:52 +0000
@@ -1,3 +1,24 @@
+2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN,
+	SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these.
+	* process.c (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.
+	(Fsignal_process): Assume SIGHUP, SIGQUIT, SIGKILL, SIGPIPE,
+	SIGALRM and SIGCHLD are defined.
+	* 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.
+	* syssignal.h (EMACS_KILLPG): Remove.  All uses replaced by 'kill'
+	with a negative pid.
+	(SIGCHLD): Remove definition, as we now assume SIGCHLD.
+	* w32proc.c (sys_kill): Support negative pids compatibly with POSIX.
+
 2012-11-29  Dmitry Antipov  <dmantipov@yandex.ru>
 
 	* xdisp.c (window_outdated): Remove eassert since it hits

=== modified file 'src/callproc.c'
--- src/callproc.c	2012-11-29 00:36:22 +0000
+++ src/callproc.c	2012-11-29 06:46:35 +0000
@@ -97,7 +97,7 @@
   CONS_TO_INTEGER (Fcar (fdpid), int, fd);
   CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
   emacs_close (fd);
-  EMACS_KILLPG (pid, SIGKILL);
+  kill (-pid, SIGKILL);
   synch_process_alive = 0;
   return Qnil;
 }
@@ -134,7 +134,7 @@
       return Qnil;
     }
 
-  if (EMACS_KILLPG (pid, SIGINT) == 0)
+  if (kill (-pid, SIGINT) == 0)
     {
       ptrdiff_t count = SPECPDL_INDEX ();
       record_unwind_protect (call_process_kill, fdpid);

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2012-11-27 05:17:07 +0000
+++ src/keyboard.c	2012-11-29 21:33:52 +0000
@@ -10689,7 +10689,7 @@
       fflush (stdout);
       reset_all_sys_modes ();
 
-#ifdef SIGTSTP			/* Support possible in later USG versions */
+#ifdef SIGTSTP
 /*
  * On systems which can suspend the current process and return to the original
  * shell, this command causes the user to end up back at the shell.

=== modified file 'src/process.c'
--- src/process.c	2012-11-27 05:17:07 +0000
+++ src/process.c	2012-11-29 21:33:52 +0000
@@ -773,13 +773,11 @@
 }
 
 
-#ifdef SIGCHLD
 /* Fdelete_process promises to immediately forget about the process, but in
    reality, Emacs needs to remember those processes until they have been
    treated by the SIGCHLD handler and waitpid has been invoked on them;
    otherwise they might fill up the kernel's process table.  */
 static Lisp_Object deleted_pid_list;
-#endif
 
 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
        doc: /* Delete PROCESS: kill it and forget about it immediately.
@@ -802,7 +800,6 @@
     }
   else if (p->infd >= 0)
     {
-#ifdef SIGCHLD
       Lisp_Object symbol;
       pid_t pid = p->pid;
 
@@ -820,7 +817,6 @@
 	deleted_pid_list
 	  = Fdelete (make_fixnum_or_float (pid), deleted_pid_list);
       else
-#endif
 	{
 	  Fkill_process (process, Qnil);
 	  /* Do this now, since remove_process will make the
@@ -1578,9 +1574,7 @@
 #ifndef WINDOWSNT
   int wait_child_setup[2];
 #endif
-#ifdef SIGCHLD
   sigset_t blocked;
-#endif
   /* Use volatile to protect variables from being clobbered by vfork.  */
   volatile int forkin, forkout;
   volatile int pty_flag = 0;
@@ -1680,13 +1674,11 @@
 
   block_input ();
 
-#ifdef SIGCHLD
   /* Block SIGCHLD until we have a chance to store the new fork's
      pid in its process structure.  */
   sigemptyset (&blocked);
   sigaddset (&blocked, SIGCHLD);
   pthread_sigmask (SIG_BLOCK, &blocked, 0);
-#endif
 
 #if HAVE_WORKING_VFORK
   /* child_setup must clobber environ on systems with true vfork.
@@ -1800,10 +1792,8 @@
       /* Emacs ignores SIGPIPE, but the child should not.  */
       signal (SIGPIPE, SIG_DFL);
 
-#ifdef SIGCHLD
 	/* Stop blocking signals in the child.  */
       pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
 
       if (pty_flag)
 	child_setup_tty (xforkout);
@@ -1828,9 +1818,7 @@
     XPROCESS (process)->alive = 1;
 
   /* Stop blocking signals in the parent.  */
-#ifdef SIGCHLD
   pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
   unblock_input ();
 
   if (pid < 0)
@@ -4622,7 +4610,7 @@
 		 yielding EBADF here or at select() call above.
 		 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
 		 in m/ibmrt-aix.h), and here we just ignore the select error.
-		 Cleanup occurs c/o status_notify after SIGCLD. */
+		 Cleanup occurs c/o status_notify after SIGCHLD. */
 	      no_avail = 1; /* Cannot depend on values returned */
 #else
 	      emacs_abort ();
@@ -4820,10 +4808,8 @@
 #endif /* HAVE_PTYS */
 	      /* If we can detect process termination, don't consider the
 		 process gone just because its pipe is closed.  */
-#ifdef SIGCHLD
 	      else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc))
 		;
-#endif
 	      else
 		{
 		  /* Preserve status of processes already terminated.  */
@@ -5686,7 +5672,7 @@
 
    If we can, we try to signal PROCESS by sending control characters
    down the pty.  This allows us to signal inferiors who have changed
-   their uid, for which killpg would return an EPERM error.  */
+   their uid, for which kill would return an EPERM error.  */
 
 static void
 process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
@@ -5824,7 +5810,7 @@
   if (!NILP (current_group))
     {
       if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
-	EMACS_KILLPG (gid, signo);
+	kill (-gid, signo);
     }
   else
     {
@@ -5832,7 +5818,7 @@
       kill (gid, signo);
     }
 #else /* ! defined (TIOCSIGSEND) */
-  EMACS_KILLPG (gid, signo);
+  kill (-gid, signo);
 #endif /* ! defined (TIOCSIGSEND) */
 }
 
@@ -5992,8 +5978,6 @@
       if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
 	name += 3;
 
-      if (0)
-	;
 #ifdef SIGUSR1
       parse_signal ("usr1", SIGUSR1);
 #endif
@@ -6001,21 +5985,15 @@
       parse_signal ("usr2", SIGUSR2);
 #endif
       parse_signal ("term", SIGTERM);
-#ifdef SIGHUP
       parse_signal ("hup", SIGHUP);
-#endif
       parse_signal ("int", SIGINT);
-#ifdef SIGQUIT
       parse_signal ("quit", SIGQUIT);
-#endif
       parse_signal ("ill", SIGILL);
       parse_signal ("abrt", SIGABRT);
 #ifdef SIGEMT
       parse_signal ("emt", SIGEMT);
 #endif
-#ifdef SIGKILL
       parse_signal ("kill", SIGKILL);
-#endif
       parse_signal ("fpe", SIGFPE);
 #ifdef SIGBUS
       parse_signal ("bus", SIGBUS);
@@ -6024,12 +6002,8 @@
 #ifdef SIGSYS
       parse_signal ("sys", SIGSYS);
 #endif
-#ifdef SIGPIPE
       parse_signal ("pipe", SIGPIPE);
-#endif
-#ifdef SIGALRM
       parse_signal ("alrm", SIGALRM);
-#endif
 #ifdef SIGURG
       parse_signal ("urg", SIGURG);
 #endif
@@ -6042,9 +6016,7 @@
 #ifdef SIGCONT
       parse_signal ("cont", SIGCONT);
 #endif
-#ifdef SIGCHLD
       parse_signal ("chld", SIGCHLD);
-#endif
 #ifdef SIGTTIN
       parse_signal ("ttin", SIGTTIN);
 #endif
@@ -6214,7 +6186,6 @@
 void
 record_child_status_change (pid_t pid, int w)
 {
-#ifdef SIGCHLD
 
   /* Record at most one child only if we already know one child that
      has exited.  */
@@ -6303,11 +6274,8 @@
       if (input_available_clear_time)
 	*input_available_clear_time = make_emacs_time (0, 0);
     }
-#endif
 }
 
-#ifdef SIGCHLD
-
 static void
 handle_child_signal (int sig)
 {
@@ -6319,8 +6287,6 @@
 {
   deliver_process_signal (sig, handle_child_signal);
 }
-
-#endif /* SIGCHLD */
 \f
 
 static Lisp_Object
@@ -7169,7 +7135,6 @@
 
   inhibit_sentinels = 0;
 
-#ifdef SIGCHLD
 #ifndef CANNOT_DUMP
   if (! noninteractive || initialized)
 #endif
@@ -7178,7 +7143,6 @@
       emacs_sigaction_init (&action, deliver_child_signal);
       sigaction (SIGCHLD, &action, 0);
     }
-#endif
 
   FD_ZERO (&input_wait_mask);
   FD_ZERO (&non_keyboard_wait_mask);
@@ -7205,9 +7169,7 @@
 #endif
 
   Vprocess_alist = Qnil;
-#ifdef SIGCHLD
   deleted_pid_list = Qnil;
-#endif
   for (i = 0; i < MAXDESC; i++)
     {
       chan_process[i] = Qnil;
@@ -7334,9 +7296,7 @@
   DEFSYM (Qlast_nonmenu_event, "last-nonmenu-event");
 
   staticpro (&Vprocess_alist);
-#ifdef SIGCHLD
   staticpro (&deleted_pid_list);
-#endif
 
 #endif	/* subprocesses */
 

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2012-11-27 03:10:32 +0000
+++ src/sysdep.c	2012-11-29 21:33:52 +0000
@@ -428,20 +428,15 @@
 void
 sys_suspend (void)
 {
-#if defined (SIGTSTP) && !defined (MSDOS)
-
-  {
-    pid_t pgrp = getpgrp ();
-    EMACS_KILLPG (pgrp, SIGTSTP);
-  }
-
-#else /* No SIGTSTP */
+#ifndef DOS_NT
+  kill (0, SIGTSTP);
+#else
 /* On a system where suspending is not implemented,
    instead fork a subshell and let it talk directly to the terminal
    while we wait.  */
   sys_subshell ();
 
-#endif /* no SIGTSTP */
+#endif
 }
 
 /* Fork a subshell.  */
@@ -1491,9 +1486,7 @@
   /* When handling a signal, block nonfatal system signals that are caught
      by Emacs.  This makes race conditions less likely.  */
   sigaddset (&action->sa_mask, SIGALRM);
-#ifdef SIGCHLD
   sigaddset (&action->sa_mask, SIGCHLD);
-#endif
 #ifdef SIGDANGER
   sigaddset (&action->sa_mask, SIGDANGER);
 #endif
@@ -1673,18 +1666,11 @@
 # ifdef SIGAIO
       sys_siglist[SIGAIO] = "LAN I/O interrupt";
 # endif
-# ifdef SIGALRM
       sys_siglist[SIGALRM] = "Alarm clock";
-# endif
 # ifdef SIGBUS
       sys_siglist[SIGBUS] = "Bus error";
 # endif
-# ifdef SIGCLD
-      sys_siglist[SIGCLD] = "Child status changed";
-# endif
-# ifdef SIGCHLD
       sys_siglist[SIGCHLD] = "Child status changed";
-# endif
 # ifdef SIGCONT
       sys_siglist[SIGCONT] = "Continued";
 # endif
@@ -1704,9 +1690,7 @@
 # ifdef SIGGRANT
       sys_siglist[SIGGRANT] = "Monitor mode granted";
 # endif
-# ifdef SIGHUP
       sys_siglist[SIGHUP] = "Hangup";
-# endif
       sys_siglist[SIGILL] = "Illegal instruction";
       sys_siglist[SIGINT] = "Interrupt";
 # ifdef SIGIO
@@ -1718,9 +1702,7 @@
 # ifdef SIGIOT
       sys_siglist[SIGIOT] = "IOT trap";
 # endif
-# ifdef SIGKILL
       sys_siglist[SIGKILL] = "Killed";
-# endif
 # ifdef SIGLOST
       sys_siglist[SIGLOST] = "Resource lost";
 # endif
@@ -1733,9 +1715,7 @@
 # ifdef SIGPHONE
       sys_siglist[SIGWIND] = "SIGPHONE";
 # endif
-# ifdef SIGPIPE
       sys_siglist[SIGPIPE] = "Broken pipe";
-# endif
 # ifdef SIGPOLL
       sys_siglist[SIGPOLL] = "Pollable event occurred";
 # endif
@@ -1748,9 +1728,7 @@
 # ifdef SIGPWR
       sys_siglist[SIGPWR] = "Power-fail restart";
 # endif
-# ifdef SIGQUIT
       sys_siglist[SIGQUIT] = "Quit";
-# endif
 # ifdef SIGRETRACT
       sys_siglist[SIGRETRACT] = "Need to relinquish monitor mode";
 # endif

=== modified file 'src/syssignal.h'
--- src/syssignal.h	2012-10-07 02:26:03 +0000
+++ src/syssignal.h	2012-11-29 06:46:35 +0000
@@ -54,26 +54,6 @@
 # define emacs_raise(sig) raise (sig)
 #endif
 
-/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
-   Must do that using the killpg call.  */
-#ifdef BSD_SYSTEM
-#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
-#else
-#ifdef WINDOWSNT
-#define EMACS_KILLPG(gid, signo) (kill (gid, signo))
-#else
-#define EMACS_KILLPG(gid, signo) (kill   (-(gid), (signo)))
-#endif
-#endif
-
-/* Define SIGCHLD as an alias for SIGCLD.  There are many conditionals
-   testing SIGCHLD.  */
-#ifdef SIGCLD
-#ifndef SIGCHLD
-#define SIGCHLD SIGCLD
-#endif /* SIGCHLD */
-#endif /* ! defined (SIGCLD) */
-
 #ifndef HAVE_STRSIGNAL
 # define strsignal(sig) safe_strsignal (sig)
 #endif

=== modified file 'src/w32proc.c'
--- src/w32proc.c	2012-11-27 03:10:32 +0000
+++ src/w32proc.c	2012-11-29 06:46:35 +0000
@@ -2139,6 +2139,10 @@
   int need_to_free = 0;
   int rc = 0;
 
+  /* Each process is in its own process group.  */
+  if (pid < 0)
+    pid = -pid;
+
   /* Only handle signals that will result in the process dying */
   if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
     {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-11-29 21:38   ` Paul Eggert
@ 2012-11-30  8:54     ` Eli Zaretskii
  2012-12-03  1:31       ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2012-11-30  8:54 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 13026

> Date: Thu, 29 Nov 2012 13:38:04 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 13026@debbugs.gnu.org
> 
> > This will break the Windows build in more than one way, unless
> > accompanied by suitable Windows-only changes.  Is this the entire
> > changeset, or did you omit some more changes?
> 
> That was the entire changeset.  I didn't know about the problems
> on MS-Windows.  I trimmed down the patch, to avoid the issues you
> raised, and am attaching a proposed revised patch.  Thanks for
> the review.

Thanks, this looks fine, except for this part:

> @@ -5992,8 +5978,6 @@
>        if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
>  	name += 3;
>  
> -      if (0)
> -	;
>  #ifdef SIGUSR1
>        parse_signal ("usr1", SIGUSR1);
>  #endif

The expansion of parse_signal starts with "else if", so it looks like
removing that ugly "if (0)" will break something like

  M-: (signal-process 'SIGINT) RET

because the unrelated 'if' before it will then be used to do nothing
useful with such signal specs.  Maybe a better fix there would be to
have an array of data (name and value of each signal), and loop
through it, instead of using if-elseif.

By the way, an alternative way of dealing with the lack of Posix
signals on Windows is to condition the related fragments on WINDOWSNT,
and remove the "#ifdef SIGFOO" conditions for Posix signals.  That
would tell more clearly why the code is being excluded, I think.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-11-30  8:54     ` Eli Zaretskii
@ 2012-12-03  1:31       ` Paul Eggert
  2012-12-04 19:17         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2012-12-03  1:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13026

[-- Attachment #1: Type: text/plain, Size: 897 bytes --]

On 11/30/2012 12:54 AM, Eli Zaretskii wrote:
> Maybe a better fix there would be to
> have an array of data (name and value of each signal), and loop
> through it, instead of using if-elseif.

Sure, that's easy enough.  Gnulib already has a module to do that.
Revised patch attached (most of the new stuff is just code
copied from Gnulib).  As a bonus, this fixes signal-process to
handle several signal names that it currently doesn't support,
such as those of the real-time signals.

> By the way, an alternative way of dealing with the lack of Posix
> signals on Windows is to condition the related fragments on WINDOWSNT,
> and remove the "#ifdef SIGFOO" conditions for Posix signals.

I'd rather use the Autoconf style, which is to test for individual
features rather than test for operating systems, as that tends to
make maintenance easier when operating systems or the emulations
mutate.


[-- Attachment #2: signal.txt --]
[-- Type: text/plain, Size: 33516 bytes --]

=== modified file 'ChangeLog'
--- ChangeLog	2012-11-30 18:25:59 +0000
+++ ChangeLog	2012-12-03 01:24:25 +0000
@@ -1,3 +1,11 @@
+2012-12-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	* 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.
+
 2012-11-30  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Merge from gnulib for 'inline' (Bug#13040), incorporating:

=== modified file 'admin/CPP-DEFINES'
--- admin/CPP-DEFINES	2012-11-24 17:20:49 +0000
+++ admin/CPP-DEFINES	2012-11-29 06:46:35 +0000
@@ -419,14 +419,7 @@
 PURESIZE
 RUN_TIME_REMAP
 SETUP_SLAVE_PTY
-SIGALRM
-SIGCHLD
-SIGHUP
-SIGKILL
 SIGNALS_VIA_CHARACTERS
-SIGPIPE
-SIGQUIT
-SIGTRAP
 STDC_HEADERS
 SYSTEM_PURESIZE_EXTRA
 SYSTEM_MALLOC

=== modified file 'admin/ChangeLog'
--- admin/ChangeLog	2012-11-24 17:20:49 +0000
+++ admin/ChangeLog	2012-12-03 01:24:25 +0000
@@ -1,3 +1,11 @@
+2012-12-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	* CPP-DEFINES (SIGALRM, SIGCHLD, SIGHUP, SIGKILL, SIGPIPE, SIGQUIT):
+	Remove.
+	(SIGTRAP): Remove this one too, as config.h no longer defines it.
+	* merge-gnulib (GNULIB_MODULES): Add sig2str.
+
 2012-11-24  Ken Brown  <kbrown@cornell.edu>
 
 	* CPP-DEFINES (HAVE_MOUSE): Remove.

=== modified file 'admin/merge-gnulib'
--- admin/merge-gnulib	2012-11-17 22:12:47 +0000
+++ admin/merge-gnulib	2012-12-03 01:24:25 +0000
@@ -32,7 +32,7 @@
   fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday
   ignore-value intprops largefile lstat
   manywarnings mktime pselect pthread_sigmask readlink
-  socklen stat-time stdalign stdarg stdbool stdio
+  sig2str socklen stat-time stdalign stdarg stdbool stdio
   strftime strtoimax strtoumax symlink sys_stat
   sys_time time timer-time timespec-add timespec-sub utimens
   warnings

=== modified file 'configure.ac'
--- configure.ac	2012-11-27 03:10:32 +0000
+++ configure.ac	2012-11-29 06:46:35 +0000
@@ -3600,7 +3600,7 @@
     AC_DEFINE(PTY_ITERATION, [])
     dnl Not used, because PTY_ITERATION is defined.
     AC_DEFINE(FIRST_PTY_LETTER, ['q'])
-    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
+    AC_DEFINE(PTY_OPEN, [ { struct sigaction ocstat, cstat; struct stat stb; char * name; sigemptyset(&cstat.sa_mask); cstat.sa_handler = SIG_DFL; cstat.sa_flags = 0; sigaction(SIGCHLD, &cstat, &ocstat); name = _getpty (&fd, O_RDWR | O_NDELAY, 0600, 0); sigaction(SIGCHLD, &ocstat, (struct sigaction *)0); if (name == 0) return -1; if (fd < 0) return -1; if (fstat (fd, &stb) < 0) return -1; strcpy (pty_name, name); }])
     dnl No need to get the pty name at all.
     AC_DEFINE(PTY_NAME_SPRINTF, [])
     dnl No need to use sprintf to get the tty name--we get that from _getpty.
@@ -3611,12 +3611,12 @@
     dnl On SysVr4, grantpt(3) forks a subprocess, so keep sigchld_handler()
     dnl from intercepting that death.  If any child but grantpt's should die
     dnl within, it should be caught after sigrelse(2).
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1 || unlockpt (fd) == -1 || !(ptyname = ptsname (fd))) { emacs_close (fd); return -1; } snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 
   unixware )
     dnl Comments are as per sol2*.
-    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
+    AC_DEFINE(PTY_TTY_NAME_SPRINTF, [{ char *ptsname (int), *ptyname; int grantpt_result; sigset_t blocked; sigemptyset (&blocked); sigaddset (&blocked, SIGCHLD); pthread_sigmask (SIG_BLOCK, &blocked, 0); grantpt_result = grantpt (fd); pthread_sigmask (SIG_UNBLOCK, &blocked, 0); if (grantpt_result == -1) fatal("could not grant slave pty"); if (unlockpt(fd) == -1) fatal("could not unlock slave pty"); if (!(ptyname = ptsname(fd))) fatal ("could not enable slave pty"); snprintf (pty_name, sizeof pty_name, "%s", ptyname); }])
     ;;
 esac
 

=== modified file 'lib/gnulib.mk'
--- lib/gnulib.mk	2012-11-30 18:25:59 +0000
+++ lib/gnulib.mk	2012-12-03 01:24:25 +0000
@@ -21,7 +21,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub utimens warnings
 
 
 MOSTLYCLEANFILES += core *.stackdump
@@ -457,6 +457,15 @@
 
 ## end   gnulib module root-uid
 
+## begin gnulib module sig2str
+
+
+EXTRA_DIST += sig2str.c sig2str.h
+
+EXTRA_libgnu_a_SOURCES += sig2str.c
+
+## end   gnulib module sig2str
+
 ## begin gnulib module signal-h
 
 BUILT_SOURCES += signal.h

=== added file 'lib/sig2str.c'
--- lib/sig2str.c	1970-01-01 00:00:00 +0000
+++ lib/sig2str.c	2012-12-03 01:24:25 +0000
@@ -0,0 +1,345 @@
+/* sig2str.c -- convert between signal names and numbers
+
+   Copyright (C) 2002, 2004, 2006, 2009-2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert.  */
+
+#include <config.h>
+
+#include <limits.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "sig2str.h"
+
+#ifndef SIGRTMIN
+# define SIGRTMIN 0
+# undef SIGRTMAX
+#endif
+#ifndef SIGRTMAX
+# define SIGRTMAX (SIGRTMIN - 1)
+#endif
+
+#define NUMNAME(name) { SIG##name, #name }
+
+/* Signal names and numbers.  Put the preferred name first.  */
+static struct numname { int num; char const name[8]; } numname_table[] =
+  {
+    /* Signals required by POSIX 1003.1-2001 base, listed in
+       traditional numeric order where possible.  */
+#ifdef SIGHUP
+    NUMNAME (HUP),
+#endif
+#ifdef SIGINT
+    NUMNAME (INT),
+#endif
+#ifdef SIGQUIT
+    NUMNAME (QUIT),
+#endif
+#ifdef SIGILL
+    NUMNAME (ILL),
+#endif
+#ifdef SIGTRAP
+    NUMNAME (TRAP),
+#endif
+#ifdef SIGABRT
+    NUMNAME (ABRT),
+#endif
+#ifdef SIGFPE
+    NUMNAME (FPE),
+#endif
+#ifdef SIGKILL
+    NUMNAME (KILL),
+#endif
+#ifdef SIGSEGV
+    NUMNAME (SEGV),
+#endif
+    /* On Haiku, SIGSEGV == SIGBUS, but we prefer SIGSEGV to match
+       strsignal.c output, so SIGBUS must be listed second.  */
+#ifdef SIGBUS
+    NUMNAME (BUS),
+#endif
+#ifdef SIGPIPE
+    NUMNAME (PIPE),
+#endif
+#ifdef SIGALRM
+    NUMNAME (ALRM),
+#endif
+#ifdef SIGTERM
+    NUMNAME (TERM),
+#endif
+#ifdef SIGUSR1
+    NUMNAME (USR1),
+#endif
+#ifdef SIGUSR2
+    NUMNAME (USR2),
+#endif
+#ifdef SIGCHLD
+    NUMNAME (CHLD),
+#endif
+#ifdef SIGURG
+    NUMNAME (URG),
+#endif
+#ifdef SIGSTOP
+    NUMNAME (STOP),
+#endif
+#ifdef SIGTSTP
+    NUMNAME (TSTP),
+#endif
+#ifdef SIGCONT
+    NUMNAME (CONT),
+#endif
+#ifdef SIGTTIN
+    NUMNAME (TTIN),
+#endif
+#ifdef SIGTTOU
+    NUMNAME (TTOU),
+#endif
+
+    /* Signals required by POSIX 1003.1-2001 with the XSI extension.  */
+#ifdef SIGSYS
+    NUMNAME (SYS),
+#endif
+#ifdef SIGPOLL
+    NUMNAME (POLL),
+#endif
+#ifdef SIGVTALRM
+    NUMNAME (VTALRM),
+#endif
+#ifdef SIGPROF
+    NUMNAME (PROF),
+#endif
+#ifdef SIGXCPU
+    NUMNAME (XCPU),
+#endif
+#ifdef SIGXFSZ
+    NUMNAME (XFSZ),
+#endif
+
+    /* Unix Version 7.  */
+#ifdef SIGIOT
+    NUMNAME (IOT),      /* Older name for ABRT.  */
+#endif
+#ifdef SIGEMT
+    NUMNAME (EMT),
+#endif
+
+    /* USG Unix.  */
+#ifdef SIGPHONE
+    NUMNAME (PHONE),
+#endif
+#ifdef SIGWIND
+    NUMNAME (WIND),
+#endif
+
+    /* Unix System V.  */
+#ifdef SIGCLD
+    NUMNAME (CLD),
+#endif
+#ifdef SIGPWR
+    NUMNAME (PWR),
+#endif
+
+    /* GNU/Linux 2.2 and Solaris 8.  */
+#ifdef SIGCANCEL
+    NUMNAME (CANCEL),
+#endif
+#ifdef SIGLWP
+    NUMNAME (LWP),
+#endif
+#ifdef SIGWAITING
+    NUMNAME (WAITING),
+#endif
+#ifdef SIGFREEZE
+    NUMNAME (FREEZE),
+#endif
+#ifdef SIGTHAW
+    NUMNAME (THAW),
+#endif
+#ifdef SIGLOST
+    NUMNAME (LOST),
+#endif
+#ifdef SIGWINCH
+    NUMNAME (WINCH),
+#endif
+
+    /* GNU/Linux 2.2.  */
+#ifdef SIGINFO
+    NUMNAME (INFO),
+#endif
+#ifdef SIGIO
+    NUMNAME (IO),
+#endif
+#ifdef SIGSTKFLT
+    NUMNAME (STKFLT),
+#endif
+
+    /* AIX 5L.  */
+#ifdef SIGDANGER
+    NUMNAME (DANGER),
+#endif
+#ifdef SIGGRANT
+    NUMNAME (GRANT),
+#endif
+#ifdef SIGMIGRATE
+    NUMNAME (MIGRATE),
+#endif
+#ifdef SIGMSG
+    NUMNAME (MSG),
+#endif
+#ifdef SIGPRE
+    NUMNAME (PRE),
+#endif
+#ifdef SIGRETRACT
+    NUMNAME (RETRACT),
+#endif
+#ifdef SIGSAK
+    NUMNAME (SAK),
+#endif
+#ifdef SIGSOUND
+    NUMNAME (SOUND),
+#endif
+
+    /* Older AIX versions.  */
+#ifdef SIGALRM1
+    NUMNAME (ALRM1),    /* unknown; taken from Bash 2.05 */
+#endif
+#ifdef SIGKAP
+    NUMNAME (KAP),      /* Older name for SIGGRANT.  */
+#endif
+#ifdef SIGVIRT
+    NUMNAME (VIRT),     /* unknown; taken from Bash 2.05 */
+#endif
+#ifdef SIGWINDOW
+    NUMNAME (WINDOW),   /* Older name for SIGWINCH.  */
+#endif
+
+    /* BeOS */
+#ifdef SIGKILLTHR
+    NUMNAME (KILLTHR),
+#endif
+
+    /* Older HP-UX versions.  */
+#ifdef SIGDIL
+    NUMNAME (DIL),
+#endif
+
+    /* Korn shell and Bash, of uncertain vintage.  */
+    { 0, "EXIT" }
+  };
+
+#define NUMNAME_ENTRIES (sizeof numname_table / sizeof numname_table[0])
+
+/* ISDIGIT differs from isdigit, as follows:
+   - Its arg may be any int or unsigned int; it need not be an unsigned char
+     or EOF.
+   - It's typically faster.
+   POSIX says that only '0' through '9' are digits.  Prefer ISDIGIT to
+   isdigit unless it's important to use the locale's definition
+   of "digit" even when the host does not conform to POSIX.  */
+#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
+
+/* Convert the signal name SIGNAME to a signal number.  Return the
+   signal number if successful, -1 otherwise.  */
+
+static int
+str2signum (char const *signame)
+{
+  if (ISDIGIT (*signame))
+    {
+      char *endp;
+      long int n = strtol (signame, &endp, 10);
+      if (! *endp && n <= SIGNUM_BOUND)
+        return n;
+    }
+  else
+    {
+      unsigned int i;
+      for (i = 0; i < NUMNAME_ENTRIES; i++)
+        if (strcmp (numname_table[i].name, signame) == 0)
+          return numname_table[i].num;
+
+      {
+        char *endp;
+        int rtmin = SIGRTMIN;
+        int rtmax = SIGRTMAX;
+
+        if (0 < rtmin && strncmp (signame, "RTMIN", 5) == 0)
+          {
+            long int n = strtol (signame + 5, &endp, 10);
+            if (! *endp && 0 <= n && n <= rtmax - rtmin)
+              return rtmin + n;
+          }
+        else if (0 < rtmax && strncmp (signame, "RTMAX", 5) == 0)
+          {
+            long int n = strtol (signame + 5, &endp, 10);
+            if (! *endp && rtmin - rtmax <= n && n <= 0)
+              return rtmax + n;
+          }
+      }
+    }
+
+  return -1;
+}
+
+/* Convert the signal name SIGNAME to the signal number *SIGNUM.
+   Return 0 if successful, -1 otherwise.  */
+
+int
+str2sig (char const *signame, int *signum)
+{
+  *signum = str2signum (signame);
+  return *signum < 0 ? -1 : 0;
+}
+
+/* Convert SIGNUM to a signal name in SIGNAME.  SIGNAME must point to
+   a buffer of at least SIG2STR_MAX bytes.  Return 0 if successful, -1
+   otherwise.  */
+
+int
+sig2str (int signum, char *signame)
+{
+  unsigned int i;
+  for (i = 0; i < NUMNAME_ENTRIES; i++)
+    if (numname_table[i].num == signum)
+      {
+        strcpy (signame, numname_table[i].name);
+        return 0;
+      }
+
+  {
+    int rtmin = SIGRTMIN;
+    int rtmax = SIGRTMAX;
+
+    if (! (rtmin <= signum && signum <= rtmax))
+      return -1;
+
+    if (signum <= rtmin + (rtmax - rtmin) / 2)
+      {
+        int delta = signum - rtmin;
+        sprintf (signame, delta ? "RTMIN+%d" : "RTMIN", delta);
+      }
+    else
+      {
+        int delta = rtmax - signum;
+        sprintf (signame, delta ? "RTMAX-%d" : "RTMAX", delta);
+      }
+
+    return 0;
+  }
+}

=== added file 'lib/sig2str.h'
--- lib/sig2str.h	1970-01-01 00:00:00 +0000
+++ lib/sig2str.h	2012-12-03 01:24:25 +0000
@@ -0,0 +1,43 @@
+/* sig2str.h -- convert between signal names and numbers
+
+   Copyright (C) 2002, 2005, 2009-2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert.  */
+
+#include <signal.h>
+
+/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig.  */
+#ifndef SIG2STR_MAX
+
+# include "intprops.h"
+
+/* Size of a buffer needed to hold a signal name like "HUP".  */
+# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
+
+int sig2str (int, char *);
+int str2sig (char const *, int *);
+
+#endif
+
+/* An upper bound on signal numbers allowed by the system.  */
+
+#if defined _sys_nsig
+# define SIGNUM_BOUND (_sys_nsig - 1)
+#elif defined NSIG
+# define SIGNUM_BOUND (NSIG - 1)
+#else
+# define SIGNUM_BOUND 64
+#endif

=== modified file 'm4/gnulib-comp.m4'
--- m4/gnulib-comp.m4	2012-11-30 18:25:59 +0000
+++ m4/gnulib-comp.m4	2012-12-03 01:24:25 +0000
@@ -87,6 +87,7 @@
   # Code from module pthread_sigmask:
   # Code from module readlink:
   # Code from module root-uid:
+  # Code from module sig2str:
   # Code from module signal-h:
   # Code from module snippet/_Noreturn:
   # Code from module snippet/arg-nonnull:
@@ -245,6 +246,11 @@
     gl_PREREQ_READLINK
   fi
   gl_UNISTD_MODULE_INDICATOR([readlink])
+  gl_FUNC_SIG2STR
+  if test $ac_cv_func_sig2str = no; then
+    AC_LIBOBJ([sig2str])
+    gl_PREREQ_SIG2STR
+  fi
   gl_SIGNAL_H
   gl_TYPE_SOCKLEN_T
   gt_TYPE_SSIZE_T
@@ -681,6 +687,8 @@
   lib/sha256.h
   lib/sha512.c
   lib/sha512.h
+  lib/sig2str.c
+  lib/sig2str.h
   lib/signal.in.h
   lib/stat-time.c
   lib/stat-time.h
@@ -760,6 +768,7 @@
   m4/sha1.m4
   m4/sha256.m4
   m4/sha512.m4
+  m4/sig2str.m4
   m4/signal_h.m4
   m4/socklen.m4
   m4/ssize_t.m4

=== added file 'm4/sig2str.m4'
--- m4/sig2str.m4	1970-01-01 00:00:00 +0000
+++ m4/sig2str.m4	2012-12-03 01:24:25 +0000
@@ -0,0 +1,15 @@
+# serial 7
+dnl Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_SIG2STR],
+[
+  AC_CHECK_FUNCS([sig2str])
+])
+
+# Prerequisites of lib/sig2str.c.
+AC_DEFUN([gl_PREREQ_SIG2STR], [
+  :
+])

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2012-12-03 01:08:31 +0000
+++ src/ChangeLog	2012-12-03 01:24:25 +0000
@@ -1,3 +1,26 @@
+2012-12-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+	Assume POSIX 1003.1-1988 or later for signal.h (Bug#13026).
+	Exceptions: do not assume SIGCONT, SIGSTOP, SIGTSTP, SIGTTIN,
+	SIGTTOU, SIGUSR1, SIGUSR2, as Microsoft platforms lack these.
+	* process.c (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.
+	(Fsignal_process): Use abbr_to_signal to convert signal names to ints.
+	* sysdep.c: Include <sig2str.h>.
+	(sys_suspend) [!DOS_NT]: Use kill (0, ...) rather than
+	kill (getpgrp (), ...).
+	(emacs_sigaction_init): Assume SIGCHLD is defined.
+	(abbr_to_signal): New function.
+	(init_signals): Assume SIGALRM, SIGCHLD, SIGHUP, SIGKILL,
+	SIGPIPE, and SIGQUIT are defined.  Do not worry about SIGCLD any more.
+	* syssignal.h (abbr_to_signal): New decl.
+	(EMACS_KILLPG): Remove.  All uses replaced by 'kill' with a negative pid.
+	(SIGCHLD): Remove definition, as we now assume SIGCHLD.
+	* w32proc.c (sys_kill): Support negative pids compatibly with POSIX.
+
 2012-12-03  Chong Yidong  <cyd@gnu.org>
 
 	* fileio.c (Vauto_save_list_file_name): Doc fix.

=== modified file 'src/callproc.c'
--- src/callproc.c	2012-12-02 19:16:45 +0000
+++ src/callproc.c	2012-12-03 01:17:59 +0000
@@ -97,7 +97,7 @@
   CONS_TO_INTEGER (Fcar (fdpid), int, fd);
   CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
   emacs_close (fd);
-  EMACS_KILLPG (pid, SIGKILL);
+  kill (-pid, SIGKILL);
   synch_process_alive = 0;
   return Qnil;
 }
@@ -134,7 +134,7 @@
       return Qnil;
     }
 
-  if (EMACS_KILLPG (pid, SIGINT) == 0)
+  if (kill (-pid, SIGINT) == 0)
     {
       ptrdiff_t count = SPECPDL_INDEX ();
       record_unwind_protect (call_process_kill, fdpid);

=== modified file 'src/keyboard.c'
--- src/keyboard.c	2012-11-27 05:17:07 +0000
+++ src/keyboard.c	2012-11-29 21:33:52 +0000
@@ -10689,7 +10689,7 @@
       fflush (stdout);
       reset_all_sys_modes ();
 
-#ifdef SIGTSTP			/* Support possible in later USG versions */
+#ifdef SIGTSTP
 /*
  * On systems which can suspend the current process and return to the original
  * shell, this command causes the user to end up back at the shell.

=== modified file 'src/process.c'
--- src/process.c	2012-12-02 19:16:45 +0000
+++ src/process.c	2012-12-03 01:24:25 +0000
@@ -773,13 +773,11 @@
 }
 
 
-#ifdef SIGCHLD
 /* Fdelete_process promises to immediately forget about the process, but in
    reality, Emacs needs to remember those processes until they have been
    treated by the SIGCHLD handler and waitpid has been invoked on them;
    otherwise they might fill up the kernel's process table.  */
 static Lisp_Object deleted_pid_list;
-#endif
 
 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
        doc: /* Delete PROCESS: kill it and forget about it immediately.
@@ -802,7 +800,6 @@
     }
   else if (p->infd >= 0)
     {
-#ifdef SIGCHLD
       Lisp_Object symbol;
       pid_t pid = p->pid;
 
@@ -820,7 +817,6 @@
 	deleted_pid_list
 	  = Fdelete (make_fixnum_or_float (pid), deleted_pid_list);
       else
-#endif
 	{
 	  Fkill_process (process, Qnil);
 	  /* Do this now, since remove_process will make the
@@ -1578,9 +1574,7 @@
 #ifndef WINDOWSNT
   int wait_child_setup[2];
 #endif
-#ifdef SIGCHLD
   sigset_t blocked;
-#endif
   /* Use volatile to protect variables from being clobbered by vfork.  */
   volatile int forkin, forkout;
   volatile int pty_flag = 0;
@@ -1677,13 +1671,11 @@
 
   block_input ();
 
-#ifdef SIGCHLD
   /* Block SIGCHLD until we have a chance to store the new fork's
      pid in its process structure.  */
   sigemptyset (&blocked);
   sigaddset (&blocked, SIGCHLD);
   pthread_sigmask (SIG_BLOCK, &blocked, 0);
-#endif
 
 #ifndef WINDOWSNT
   pid = vfork ();
@@ -1791,10 +1783,8 @@
       /* Emacs ignores SIGPIPE, but the child should not.  */
       signal (SIGPIPE, SIG_DFL);
 
-#ifdef SIGCHLD
 	/* Stop blocking signals in the child.  */
       pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
 
       if (pty_flag)
 	child_setup_tty (xforkout);
@@ -1815,9 +1805,7 @@
     XPROCESS (process)->alive = 1;
 
   /* Stop blocking signals in the parent.  */
-#ifdef SIGCHLD
   pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
-#endif
   unblock_input ();
 
   if (pid < 0)
@@ -4609,7 +4597,7 @@
 		 yielding EBADF here or at select() call above.
 		 So, SIGHUP is ignored (see def of PTY_TTY_NAME_SPRINTF
 		 in m/ibmrt-aix.h), and here we just ignore the select error.
-		 Cleanup occurs c/o status_notify after SIGCLD. */
+		 Cleanup occurs c/o status_notify after SIGCHLD. */
 	      no_avail = 1; /* Cannot depend on values returned */
 #else
 	      emacs_abort ();
@@ -4807,10 +4795,8 @@
 #endif /* HAVE_PTYS */
 	      /* If we can detect process termination, don't consider the
 		 process gone just because its pipe is closed.  */
-#ifdef SIGCHLD
 	      else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc))
 		;
-#endif
 	      else
 		{
 		  /* Preserve status of processes already terminated.  */
@@ -5673,7 +5659,7 @@
 
    If we can, we try to signal PROCESS by sending control characters
    down the pty.  This allows us to signal inferiors who have changed
-   their uid, for which killpg would return an EPERM error.  */
+   their uid, for which kill would return an EPERM error.  */
 
 static void
 process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
@@ -5811,7 +5797,7 @@
   if (!NILP (current_group))
     {
       if (ioctl (p->infd, TIOCSIGSEND, signo) == -1)
-	EMACS_KILLPG (gid, signo);
+	kill (-gid, signo);
     }
   else
     {
@@ -5819,7 +5805,7 @@
       kill (gid, signo);
     }
 #else /* ! defined (TIOCSIGSEND) */
-  EMACS_KILLPG (gid, signo);
+  kill (-gid, signo);
 #endif /* ! defined (TIOCSIGSEND) */
 }
 
@@ -5934,6 +5920,7 @@
   (Lisp_Object process, Lisp_Object sigcode)
 {
   pid_t pid;
+  int signo;
 
   if (STRINGP (process))
     {
@@ -5963,12 +5950,11 @@
 	error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
     }
 
-#define parse_signal(NAME, VALUE)		\
-  else if (!xstrcasecmp (name, NAME))		\
-    XSETINT (sigcode, VALUE)
-
   if (INTEGERP (sigcode))
-    CHECK_TYPE_RANGED_INTEGER (int, sigcode);
+    {
+      CHECK_TYPE_RANGED_INTEGER (int, sigcode);
+      signo = XINT (sigcode);
+    }
   else
     {
       char *name;
@@ -5976,96 +5962,12 @@
       CHECK_SYMBOL (sigcode);
       name = SSDATA (SYMBOL_NAME (sigcode));
 
-      if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
-	name += 3;
-
-      if (0)
-	;
-#ifdef SIGUSR1
-      parse_signal ("usr1", SIGUSR1);
-#endif
-#ifdef SIGUSR2
-      parse_signal ("usr2", SIGUSR2);
-#endif
-      parse_signal ("term", SIGTERM);
-#ifdef SIGHUP
-      parse_signal ("hup", SIGHUP);
-#endif
-      parse_signal ("int", SIGINT);
-#ifdef SIGQUIT
-      parse_signal ("quit", SIGQUIT);
-#endif
-      parse_signal ("ill", SIGILL);
-      parse_signal ("abrt", SIGABRT);
-#ifdef SIGEMT
-      parse_signal ("emt", SIGEMT);
-#endif
-#ifdef SIGKILL
-      parse_signal ("kill", SIGKILL);
-#endif
-      parse_signal ("fpe", SIGFPE);
-#ifdef SIGBUS
-      parse_signal ("bus", SIGBUS);
-#endif
-      parse_signal ("segv", SIGSEGV);
-#ifdef SIGSYS
-      parse_signal ("sys", SIGSYS);
-#endif
-#ifdef SIGPIPE
-      parse_signal ("pipe", SIGPIPE);
-#endif
-#ifdef SIGALRM
-      parse_signal ("alrm", SIGALRM);
-#endif
-#ifdef SIGURG
-      parse_signal ("urg", SIGURG);
-#endif
-#ifdef SIGSTOP
-      parse_signal ("stop", SIGSTOP);
-#endif
-#ifdef SIGTSTP
-      parse_signal ("tstp", SIGTSTP);
-#endif
-#ifdef SIGCONT
-      parse_signal ("cont", SIGCONT);
-#endif
-#ifdef SIGCHLD
-      parse_signal ("chld", SIGCHLD);
-#endif
-#ifdef SIGTTIN
-      parse_signal ("ttin", SIGTTIN);
-#endif
-#ifdef SIGTTOU
-      parse_signal ("ttou", SIGTTOU);
-#endif
-#ifdef SIGIO
-      parse_signal ("io", SIGIO);
-#endif
-#ifdef SIGXCPU
-      parse_signal ("xcpu", SIGXCPU);
-#endif
-#ifdef SIGXFSZ
-      parse_signal ("xfsz", SIGXFSZ);
-#endif
-#ifdef SIGVTALRM
-      parse_signal ("vtalrm", SIGVTALRM);
-#endif
-#ifdef SIGPROF
-      parse_signal ("prof", SIGPROF);
-#endif
-#ifdef SIGWINCH
-      parse_signal ("winch", SIGWINCH);
-#endif
-#ifdef SIGINFO
-      parse_signal ("info", SIGINFO);
-#endif
-      else
+      signo = abbr_to_signal (name);
+      if (signo < 0)
 	error ("Undefined signal name %s", name);
     }
 
-#undef parse_signal
-
-  return make_number (kill (pid, XINT (sigcode)));
+  return make_number (kill (pid, signo));
 }
 
 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
@@ -6201,7 +6103,6 @@
 void
 record_child_status_change (pid_t pid, int w)
 {
-#ifdef SIGCHLD
 
   /* Record at most one child only if we already know one child that
      has exited.  */
@@ -6290,11 +6191,8 @@
       if (input_available_clear_time)
 	*input_available_clear_time = make_emacs_time (0, 0);
     }
-#endif
 }
 
-#ifdef SIGCHLD
-
 static void
 handle_child_signal (int sig)
 {
@@ -6306,8 +6204,6 @@
 {
   deliver_process_signal (sig, handle_child_signal);
 }
-
-#endif /* SIGCHLD */
 \f
 
 static Lisp_Object
@@ -7156,7 +7052,6 @@
 
   inhibit_sentinels = 0;
 
-#ifdef SIGCHLD
 #ifndef CANNOT_DUMP
   if (! noninteractive || initialized)
 #endif
@@ -7165,7 +7060,6 @@
       emacs_sigaction_init (&action, deliver_child_signal);
       sigaction (SIGCHLD, &action, 0);
     }
-#endif
 
   FD_ZERO (&input_wait_mask);
   FD_ZERO (&non_keyboard_wait_mask);
@@ -7192,9 +7086,7 @@
 #endif
 
   Vprocess_alist = Qnil;
-#ifdef SIGCHLD
   deleted_pid_list = Qnil;
-#endif
   for (i = 0; i < MAXDESC; i++)
     {
       chan_process[i] = Qnil;
@@ -7321,9 +7213,7 @@
   DEFSYM (Qlast_nonmenu_event, "last-nonmenu-event");
 
   staticpro (&Vprocess_alist);
-#ifdef SIGCHLD
   staticpro (&deleted_pid_list);
-#endif
 
 #endif	/* subprocesses */
 

=== modified file 'src/sysdep.c'
--- src/sysdep.c	2012-11-27 03:10:32 +0000
+++ src/sysdep.c	2012-12-03 01:24:25 +0000
@@ -34,6 +34,7 @@
 #include <c-ctype.h>
 #include <careadlinkat.h>
 #include <ignore-value.h>
+#include <sig2str.h>
 #include <utimens.h>
 
 #include "lisp.h"
@@ -428,20 +429,15 @@
 void
 sys_suspend (void)
 {
-#if defined (SIGTSTP) && !defined (MSDOS)
-
-  {
-    pid_t pgrp = getpgrp ();
-    EMACS_KILLPG (pgrp, SIGTSTP);
-  }
-
-#else /* No SIGTSTP */
+#ifndef DOS_NT
+  kill (0, SIGTSTP);
+#else
 /* On a system where suspending is not implemented,
    instead fork a subshell and let it talk directly to the terminal
    while we wait.  */
   sys_subshell ();
 
-#endif /* no SIGTSTP */
+#endif
 }
 
 /* Fork a subshell.  */
@@ -1491,9 +1487,7 @@
   /* When handling a signal, block nonfatal system signals that are caught
      by Emacs.  This makes race conditions less likely.  */
   sigaddset (&action->sa_mask, SIGALRM);
-#ifdef SIGCHLD
   sigaddset (&action->sa_mask, SIGCHLD);
-#endif
 #ifdef SIGDANGER
   sigaddset (&action->sa_mask, SIGDANGER);
 #endif
@@ -1654,6 +1648,27 @@
     sigaction (sig, &process_fatal_action, 0);
 }
 
+/* Return the integer value of the signal whose abbreviation is ABBR,
+   or a negative number if there is no such signal.  */
+int
+abbr_to_signal (char const *name)
+{
+  int i, signo;
+  char sigbuf[20]; /* Large enough for all valid signal abbreviations.  */
+
+  if (!strncmp (name, "SIG", 3) || !strncmp (name, "sig", 3))
+    name += 3;
+
+  for (i = 0; i < sizeof sigbuf; i++)
+    {
+      sigbuf[i] = c_toupper (name[i]);
+      if (! sigbuf[i])
+	return str2sig (sigbuf, &signo) == 0 ? signo : -1;
+    }
+
+  return -1;
+}
+
 void
 init_signals (bool dumping)
 {
@@ -1673,18 +1688,11 @@
 # ifdef SIGAIO
       sys_siglist[SIGAIO] = "LAN I/O interrupt";
 # endif
-# ifdef SIGALRM
       sys_siglist[SIGALRM] = "Alarm clock";
-# endif
 # ifdef SIGBUS
       sys_siglist[SIGBUS] = "Bus error";
 # endif
-# ifdef SIGCLD
-      sys_siglist[SIGCLD] = "Child status changed";
-# endif
-# ifdef SIGCHLD
       sys_siglist[SIGCHLD] = "Child status changed";
-# endif
 # ifdef SIGCONT
       sys_siglist[SIGCONT] = "Continued";
 # endif
@@ -1704,9 +1712,7 @@
 # ifdef SIGGRANT
       sys_siglist[SIGGRANT] = "Monitor mode granted";
 # endif
-# ifdef SIGHUP
       sys_siglist[SIGHUP] = "Hangup";
-# endif
       sys_siglist[SIGILL] = "Illegal instruction";
       sys_siglist[SIGINT] = "Interrupt";
 # ifdef SIGIO
@@ -1718,9 +1724,7 @@
 # ifdef SIGIOT
       sys_siglist[SIGIOT] = "IOT trap";
 # endif
-# ifdef SIGKILL
       sys_siglist[SIGKILL] = "Killed";
-# endif
 # ifdef SIGLOST
       sys_siglist[SIGLOST] = "Resource lost";
 # endif
@@ -1733,9 +1737,7 @@
 # ifdef SIGPHONE
       sys_siglist[SIGWIND] = "SIGPHONE";
 # endif
-# ifdef SIGPIPE
       sys_siglist[SIGPIPE] = "Broken pipe";
-# endif
 # ifdef SIGPOLL
       sys_siglist[SIGPOLL] = "Pollable event occurred";
 # endif
@@ -1748,9 +1750,7 @@
 # ifdef SIGPWR
       sys_siglist[SIGPWR] = "Power-fail restart";
 # endif
-# ifdef SIGQUIT
       sys_siglist[SIGQUIT] = "Quit";
-# endif
 # ifdef SIGRETRACT
       sys_siglist[SIGRETRACT] = "Need to relinquish monitor mode";
 # endif

=== modified file 'src/syssignal.h'
--- src/syssignal.h	2012-10-07 02:26:03 +0000
+++ src/syssignal.h	2012-12-03 01:24:25 +0000
@@ -20,6 +20,7 @@
 #include <signal.h>
 #include <stdbool.h>
 
+extern int abbr_to_signal (char const *);
 extern void init_signals (bool);
 
 #ifdef HAVE_PTHREAD
@@ -54,26 +55,6 @@
 # define emacs_raise(sig) raise (sig)
 #endif
 
-/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
-   Must do that using the killpg call.  */
-#ifdef BSD_SYSTEM
-#define EMACS_KILLPG(gid, signo) (killpg ( (gid), (signo)))
-#else
-#ifdef WINDOWSNT
-#define EMACS_KILLPG(gid, signo) (kill (gid, signo))
-#else
-#define EMACS_KILLPG(gid, signo) (kill   (-(gid), (signo)))
-#endif
-#endif
-
-/* Define SIGCHLD as an alias for SIGCLD.  There are many conditionals
-   testing SIGCHLD.  */
-#ifdef SIGCLD
-#ifndef SIGCHLD
-#define SIGCHLD SIGCLD
-#endif /* SIGCHLD */
-#endif /* ! defined (SIGCLD) */
-
 #ifndef HAVE_STRSIGNAL
 # define strsignal(sig) safe_strsignal (sig)
 #endif

=== modified file 'src/w32proc.c'
--- src/w32proc.c	2012-11-27 03:10:32 +0000
+++ src/w32proc.c	2012-11-29 06:46:35 +0000
@@ -2139,6 +2139,10 @@
   int need_to_free = 0;
   int rc = 0;
 
+  /* Each process is in its own process group.  */
+  if (pid < 0)
+    pid = -pid;
+
   /* Only handle signals that will result in the process dying */
   if (sig != SIGINT && sig != SIGKILL && sig != SIGQUIT && sig != SIGHUP)
     {


^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-12-03  1:31       ` Paul Eggert
@ 2012-12-04 19:17         ` Eli Zaretskii
  2012-12-08  2:40           ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2012-12-04 19:17 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 13026

> Date: Sun, 02 Dec 2012 17:31:48 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 13026@debbugs.gnu.org
> 
> On 11/30/2012 12:54 AM, Eli Zaretskii wrote:
> > Maybe a better fix there would be to
> > have an array of data (name and value of each signal), and loop
> > through it, instead of using if-elseif.
> 
> Sure, that's easy enough.  Gnulib already has a module to do that.
> Revised patch attached (most of the new stuff is just code
> copied from Gnulib).  As a bonus, this fixes signal-process to
> handle several signal names that it currently doesn't support,
> such as those of the real-time signals.

Thanks.

This will need additions to lib/makefile.w32-in, to get the new
modules to compile into libgnu.a.

> > By the way, an alternative way of dealing with the lack of Posix
> > signals on Windows is to condition the related fragments on WINDOWSNT,
> > and remove the "#ifdef SIGFOO" conditions for Posix signals.
> 
> I'd rather use the Autoconf style, which is to test for individual
> features rather than test for operating systems, as that tends to
> make maintenance easier when operating systems or the emulations
> mutate.

The likes of "#ifdef SIGFOO" are not Autoconf tests.  They test macros
defined in header files, exactly like "#ifdef WINDOWSNT" does.

The advantage of the latter is that it clearly says why, say, SIGTSTP
is not used unconditionally, which could otherwise puzzle someone who
knows that this signal is universally supported by Posix platforms.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-12-04 19:17         ` Eli Zaretskii
@ 2012-12-08  2:40           ` Paul Eggert
  2012-12-08 10:09             ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2012-12-08  2:40 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 13026-done

On 12/04/2012 11:17 AM, Eli Zaretskii wrote:

> This will need additions to lib/makefile.w32-in, to get the new
> modules to compile into libgnu.a.

I added enough so that I think it should compile, as trunk bzr
111151, and I'm marking this bug as fixed.  Someone with
Microsoft expertise should look at that as I expect more
needs to be added to the Microsoftish build procedure.

As an aside, it'd be nicer if lib/Makefile were computed more
automatically from lib/gnulib.mk on Microsoft platforms, so
that this sort of thing wouldn't require manual editing.

> The likes of "#ifdef SIGFOO" are not Autoconf tests.

Yes, but I was talking more about the Autoconf style, which is to
look for individual features rather than operating systems.  This
style tends to work better when porting among a large number of
platforms.  The style doesn't always require Autoconf help.
It's true that the style has some downsides too, but they're less
important in practice.  Here, in particular, I don't expect
many readers of the Emacs source code would think that
Emacs works only on POSIXish platforms, given all the
occurrences of "#ifdef WINDOWSNT" and "#ifdef DOS_NT" that
they'd find with even a casual perusal.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#13026: Assume POSIX 1003.1-1988 or later for signal.h.
  2012-12-08  2:40           ` Paul Eggert
@ 2012-12-08 10:09             ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2012-12-08 10:09 UTC (permalink / raw)
  To: Paul Eggert; +Cc: 13026

> Date: Fri, 07 Dec 2012 18:40:57 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: 13026-done@debbugs.gnu.org
> 
> On 12/04/2012 11:17 AM, Eli Zaretskii wrote:
> 
> > This will need additions to lib/makefile.w32-in, to get the new
> > modules to compile into libgnu.a.
> 
> I added enough so that I think it should compile, as trunk bzr
> 111151, and I'm marking this bug as fixed.  Someone with
> Microsoft expertise should look at that as I expect more
> needs to be added to the Microsoftish build procedure.

Thanks.  There was a stray character at the beginning of the file
which I removed, and I added a dependency for sig2str.o.  Otherwise,
the Windows build went smoothly.

> As an aside, it'd be nicer if lib/Makefile were computed more
> automatically from lib/gnulib.mk on Microsoft platforms, so
> that this sort of thing wouldn't require manual editing.

This is an issue that transcends the context of this bug report, so I
will reply on emacs-devel.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-08 10:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29  6:52 bug#13026: Assume POSIX 1003.1-1988 or later for signal.h Paul Eggert
2012-11-29 17:33 ` Eli Zaretskii
2012-11-29 21:38   ` Paul Eggert
2012-11-30  8:54     ` Eli Zaretskii
2012-12-03  1:31       ` Paul Eggert
2012-12-04 19:17         ` Eli Zaretskii
2012-12-08  2:40           ` Paul Eggert
2012-12-08 10:09             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).