configure: new option --enable-gcc-warnings
[bpt/emacs.git] / src / process.c
index ba3eeb8..f14de47 100644 (file)
@@ -1,6 +1,6 @@
 /* Asynchronous subprocess control for GNU Emacs.
 
-Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2011
+Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2012
   Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -120,6 +120,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "nsterm.h"
 #endif
 
+/* Work around GCC 4.7.0 bug with strict overflow checking; see
+   <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
+   These lines can be removed once the GCC bug is fixed.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wstrict-overflow"
+#endif
+
 Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
 Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
 Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
@@ -1521,8 +1528,9 @@ start_process_unwind (Lisp_Object proc)
   if (!PROCESSP (proc))
     abort ();
 
-  /* Was PROC started successfully?  */
-  if (XPROCESS (proc)->pid == -1)
+  /* Was PROC started successfully?
+     -2 is used for a pty with no process, eg for gdb.  */
+  if (XPROCESS (proc)->pid <= 0 && XPROCESS (proc)->pid != -2)
     remove_process (proc);
 
   return Qnil;
@@ -3474,7 +3482,7 @@ usage: (make-network-process &rest ARGS)  */)
 
   {
     /* Setup coding systems for communicating with the network stream.  */
-    struct gcpro inner_gcpro1;
+    struct gcpro gcpro1;
     /* Qt denotes we have not yet called Ffind_operation_coding_system.  */
     Lisp_Object coding_systems = Qt;
     Lisp_Object fargs[5], val;
@@ -3491,7 +3499,7 @@ usage: (make-network-process &rest ARGS)  */)
             || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
       /* We dare not decode end-of-line format by setting VAL to
         Qraw_text, because the existing Emacs Lisp libraries
-        assume that they receive bare code including a sequene of
+        assume that they receive bare code including a sequence of
         CR LF.  */
       val = Qnil;
     else
@@ -3502,9 +3510,9 @@ usage: (make-network-process &rest ARGS)  */)
          {
            fargs[0] = Qopen_network_stream, fargs[1] = name,
              fargs[2] = buffer, fargs[3] = host, fargs[4] = service;
-           GCPRO1_VAR (proc, inner_gcpro);
+           GCPRO1 (proc);
            coding_systems = Ffind_operation_coding_system (5, fargs);
-           UNGCPRO_VAR (inner_gcpro);
+           UNGCPRO;
          }
        if (CONSP (coding_systems))
          val = XCAR (coding_systems);
@@ -3535,9 +3543,9 @@ usage: (make-network-process &rest ARGS)  */)
              {
                fargs[0] = Qopen_network_stream, fargs[1] = name,
                  fargs[2] = buffer, fargs[3] = host, fargs[4] = service;
-               GCPRO1_VAR (proc, inner_gcpro);
+               GCPRO1 (proc);
                coding_systems = Ffind_operation_coding_system (5, fargs);
-               UNGCPRO_VAR (inner_gcpro);
+               UNGCPRO;
              }
          }
        if (CONSP (coding_systems))
@@ -4887,15 +4895,20 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
                 It can't hurt.  */
              else if (nread == -1 && errno == EIO)
                {
-                 /* Clear the descriptor now, so we only raise the signal once.  */
-                 FD_CLR (channel, &input_wait_mask);
-                 FD_CLR (channel, &non_keyboard_wait_mask);
-
-                 kill (getpid (), SIGCHLD);
+                  /* Don't do anything if only a pty, with no associated
+                    process (bug#10933).  */
+                  if (XPROCESS (proc)->pid != -2) {
+                    /* Clear the descriptor now, so we only raise the signal
+                      once.  */
+                    FD_CLR (channel, &input_wait_mask);
+                    FD_CLR (channel, &non_keyboard_wait_mask);
+                    
+                    kill (getpid (), SIGCHLD);
+                  }
                }
 #endif /* HAVE_PTYS */
-             /* If we can detect process termination, don't consider the process
-                gone just because its pipe is closed.  */
+             /* 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))
                ;
@@ -5059,9 +5072,8 @@ read_process_output (Lisp_Object proc, register int channel)
          proc_buffered_char[channel] = -1;
        }
 #ifdef HAVE_GNUTLS
-      if (XPROCESS (proc)->gnutls_p)
-       nbytes = emacs_gnutls_read (XPROCESS (proc),
-                                   chars + carryover + buffered,
+      if (p->gnutls_p)
+       nbytes = emacs_gnutls_read (p, chars + carryover + buffered,
                                    readmax - buffered);
       else
 #endif
@@ -5526,9 +5538,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
 #endif
                {
 #ifdef HAVE_GNUTLS
-                 if (XPROCESS (proc)->gnutls_p)
-                   written = emacs_gnutls_write (XPROCESS (proc),
-                                                  buf, this);
+                 if (p->gnutls_p)
+                   written = emacs_gnutls_write (p, buf, this);
                  else
 #endif
                    written = emacs_write (outfd, buf, this);