Merge from emacs-24; up to 2012-12-19T19:51:40Z!monnier@iro.umontreal.ca
authorGlenn Morris <rgm@gnu.org>
Fri, 15 Feb 2013 17:31:12 +0000 (09:31 -0800)
committerGlenn Morris <rgm@gnu.org>
Fri, 15 Feb 2013 17:31:12 +0000 (09:31 -0800)
1  2 
doc/lispref/ChangeLog
src/ChangeLog
src/w32.c
src/w32proc.c

@@@ -1,4 -1,4 +1,4 @@@
--2013-02-14  Glenn Morris  <rgm@gnu.org>
++2013-02-15  Glenn Morris  <rgm@gnu.org>
  
        * modes.texi (Basic Major Modes): 'z' no longer bound in special-mode.
  
diff --cc src/ChangeLog
@@@ -1,18 -1,38 +1,42 @@@
 -2013-02-14  Paul Eggert  <eggert@cs.ucla.edu>
 -
 -      Backport GCPRO fix from trunk (Bug#13650).
 -      The bug was reported for AIX before today's changes.
 -      I reproduced the problem on Fedora 17 x86-64 when setting
 -      GC_MARK_STACK by hand, and I presume it occurs with default
 -      configurations on HP-UX and Unixware.
 -      Trunk fix on 2013-01-14 by Dmitry Antipov <dmantipov@yandex.ru>:
 -      Fix compilation with GC_MARK_STACK == GC_USE_GCPROS_AS_BEFORE.
 -      * eval.c (eval_sub): Protect `form' from being GCed before its
 -      car and cdr becomes protected with the backtrace entry.
+ 2013-02-15  Eli Zaretskii  <eliz@gnu.org>
+       * w32proc.c (new_child): Free up to 2 slots of dead processes at a
+       time.  Improve diagnostics in DebPrint.
+       (reader_thread): If cp->char_avail is NULL, set the FILE_AT_EOF
+       flag, so that sys_select could have a chance of noticing that this
+       process is dead, and call a SIGCHLD handler for it.  Improve
+       diagnostics in DebPrint.
+       (reap_subprocess): Reset the FILE_AT_EOF flag set by
+       reader_thread.
+       (sys_select): Watch a process whose procinfo.hProcess is non-NULL
+       even if its char_avail is NULL.  Allows to reap subprocesses that
+       were forcibly deleted by delete-process.  (Bug#13546)
+       * w32.c (sys_socket, sys_bind, sys_connect, sys_gethostname)
+       (sys_gethostbyname, sys_getservbyname, sys_getpeername)
+       (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname)
+       (sys_accept, sys_recvfrom, sys_sendto, fcntl): In case of failure,
+       make sure errno is set to an appropriate value.  (Bug#13546)
+       (socket_to_fd): Add assertion against indexing fd_info[] with a
+       value that is out of bounds.
+       (sys_accept): If fd is negative, do not set up the child_process
+       structure for reading.
 +2013-02-15  Dmitry Antipov  <dmantipov@yandex.ru>
 +
 +      * composite.c (fill_gstring_header): Remove useless prototype.
 +      Break long line.
 +      * lisp.h (message_dolog, compile_pattern): Adjust prototype.
 +      * print.c (PRINTDECLARE, print_object):
 +      * search.c (compile_pattern, fast_looking_at, search_buffer):
 +      (simple_search, boyer_moore, Freplace_match):
 +      * xdisp.c (c_string_pos, number_of_chars, message_dolog):
 +      (get_overlay_arrow_glyph_row, display_mode_element):
 +      (decode_mode_spec_coding, message3):
 +      * xfaces.c (face_at_string_position): Use bool for booleans.
 +      Adjust comments.
 +
 +2013-02-15  Paul Eggert  <eggert@cs.ucla.edu>
  
        Fix AIX port (Bug#13650).
        * lisp.h (XPNTR) [!USE_LSB_TAG && DATA_SEG_BITS]:
diff --cc src/w32.c
Simple merge
diff --cc src/w32proc.c
@@@ -997,11 -990,17 +1012,22 @@@ reader_thread (void *arg
        else
        rc = _sys_read_ahead (cp->fd);
  
 +      /* Don't bother waiting for the event if we already have been
 +       told to exit by delete_child.  */
 +      if (cp->status == STATUS_READ_ERROR || !cp->char_avail)
 +      break;
 +
+       if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess && cp->fd >= 0)
+       {
+         /* Somebody already called delete_child on this child, since
+            only delete_child zeroes out cp->char_avail.  This means
+            no one will read from cp->fd and will not set the
+            FILE_AT_EOF flag, therefore preventing sys_select from
+            noticing that the process died.  Set the flag here
+            instead.  */
+         fd_info[cp->fd].flags |= FILE_AT_EOF;
+       }
        /* The name char_avail is a misnomer - it really just means the
         read-ahead has completed, whether successfully or not. */
        if (!SetEvent (cp->char_avail))
@@@ -1204,21 -1162,25 +1231,26 @@@ reap_subprocess (child_process *cp
        cp->procinfo.hThread = NULL;
      }
  
 -  /* For asynchronous children, the child_proc resources will be freed
 -     when the last pipe read descriptor is closed; for synchronous
 -     children, we must explicitly free the resources now because
 -     register_child has not been called. */
 -  if (cp->fd == -1)
 +  /* If cp->fd was not closed yet, we might be still reading the
 +     process output, so don't free its resources just yet.  The call
 +     to delete_child on behalf of this subprocess will be made by
 +     sys_read when the subprocess output is fully read.  */
 +  if (cp->fd < 0)
      delete_child (cp);
+   else
+     {
+       /* Reset the flag set by reader_thread.  */
+       fd_info[cp->fd].flags &= ~FILE_AT_EOF;
+     }
  }
  
 -/* Wait for any of our existing child processes to die
 -   When it does, close its handle
 -   Return the pid and fill in the status if non-NULL.  */
 +/* Wait for a child process specified by PID, or for any of our
 +   existing child processes (if PID is nonpositive) to die.  When it
 +   does, close its handle.  Return the pid of the process that died
 +   and fill in STATUS if non-NULL.  */
  
 -int
 -sys_wait (int *status)
 +pid_t
 +waitpid (pid_t pid, int *status, int options)
  {
    DWORD active, retval;
    int nh;