aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorEli Zaretskii2012-12-29 12:09:49 +0200
committerEli Zaretskii2012-12-29 12:09:49 +0200
commite7ae8039c346fd296c49ceedb718896bf4b27d9a (patch)
treee5d24f0802b6ffbcd0a9c1a8f4e6d5b1f40c8867 /src/w32proc.c
parent43ebd12b9a838196e91048ef09c5dba7368ee898 (diff)
downloademacs-e7ae8039c346fd296c49ceedb718896bf4b27d9a.tar.gz
emacs-e7ae8039c346fd296c49ceedb718896bf4b27d9a.zip
More cleanup in handling subprocess exiting on MS-Windows.
src/w32proc.c (reader_thread): Avoid passing NULL handles to SetEvent and WaitForSingleObject.
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 5c43a57db29..8977ca38a15 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -970,6 +970,11 @@ reader_thread (void *arg)
970 else 970 else
971 rc = _sys_read_ahead (cp->fd); 971 rc = _sys_read_ahead (cp->fd);
972 972
973 /* Don't bother waiting for the event if we already have been
974 told to exit by delete_child. */
975 if (cp->status == STATUS_READ_ERROR || !cp->char_avail)
976 break;
977
973 /* The name char_avail is a misnomer - it really just means the 978 /* The name char_avail is a misnomer - it really just means the
974 read-ahead has completed, whether successfully or not. */ 979 read-ahead has completed, whether successfully or not. */
975 if (!SetEvent (cp->char_avail)) 980 if (!SetEvent (cp->char_avail))
@@ -986,6 +991,11 @@ reader_thread (void *arg)
986 if (rc == STATUS_READ_FAILED) 991 if (rc == STATUS_READ_FAILED)
987 break; 992 break;
988 993
994 /* Don't bother waiting for the acknowledge if we already have
995 been told to exit by delete_child. */
996 if (cp->status == STATUS_READ_ERROR || !cp->char_consumed)
997 break;
998
989 /* Wait until our input is acknowledged before reading again */ 999 /* Wait until our input is acknowledged before reading again */
990 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0) 1000 if (WaitForSingleObject (cp->char_consumed, INFINITE) != WAIT_OBJECT_0)
991 { 1001 {
@@ -993,6 +1003,8 @@ reader_thread (void *arg)
993 "%lu for fd %ld\n", GetLastError (), cp->fd)); 1003 "%lu for fd %ld\n", GetLastError (), cp->fd));
994 break; 1004 break;
995 } 1005 }
1006 /* delete_child sets status to STATUS_READ_ERROR when it wants
1007 us to exit. */
996 if (cp->status == STATUS_READ_ERROR) 1008 if (cp->status == STATUS_READ_ERROR)
997 break; 1009 break;
998 } 1010 }