]> git.eshelyaron.com Git - emacs.git/commitdiff
More cleanup in handling subprocess exiting on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Sat, 29 Dec 2012 10:09:49 +0000 (12:09 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 29 Dec 2012 10:09:49 +0000 (12:09 +0200)
 src/w32proc.c (reader_thread): Avoid passing NULL handles to
 SetEvent and WaitForSingleObject.

src/ChangeLog
src/w32proc.c

index 79d1982cc0e064b71b39c0126f43543b02646171..76f6865972cde8baba5116b37022ca92208f22a1 100644 (file)
@@ -1,3 +1,8 @@
+2012-12-29  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32proc.c (reader_thread): Avoid passing NULL handles to
+       SetEvent and WaitForSingleObject.
+
 2012-12-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        Port EXTERNALLY_VISIBLE to Clang 3.2.
index 5c43a57db29568fde5001a794a796eafaf1867cb..8977ca38a1588370f14e9bb6b472dd15a6a82a18 100644 (file)
@@ -970,6 +970,11 @@ 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;
+
       /* 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))
@@ -986,6 +991,11 @@ reader_thread (void *arg)
       if (rc == STATUS_READ_FAILED)
        break;
 
+      /* Don't bother waiting for the acknowledge if we already have
+        been told to exit by delete_child.  */
+      if (cp->status == STATUS_READ_ERROR || !cp->char_consumed)
+       break;
+
       /* Wait until our input is acknowledged before reading again */
       if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
         {
@@ -993,6 +1003,8 @@ reader_thread (void *arg)
                     "%lu for fd %ld\n", GetLastError (), cp->fd));
          break;
         }
+      /* delete_child sets status to STATUS_READ_ERROR when it wants
+        us to exit.  */
       if (cp->status == STATUS_READ_ERROR)
        break;
     }