Cleanup related to bug #13546 with subprocesses on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Wed, 13 Feb 2013 17:00:26 +0000 (19:00 +0200)
committerEli Zaretskii <eliz@gnu.org>
Wed, 13 Feb 2013 17:00:26 +0000 (19:00 +0200)
 src/w32.c (sys_pipe): When failing due to file descriptors above
 MAXDESC, set errno to EMFILE.
 (_sys_read_ahead): Update cp->status when failing to read serial
 communications input, so that the status doesn't stay at
 STATUS_READ_IN_PROGRESS.

src/ChangeLog
src/w32.c

index 62d33e1..358f25b 100644 (file)
@@ -1,3 +1,11 @@
+2013-02-13  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32.c (sys_pipe): When failing due to file descriptors above
+       MAXDESC, set errno to EMFILE.
+       (_sys_read_ahead): Update cp->status when failing to read serial
+       communications input, so that the status doesn't stay at
+       STATUS_READ_IN_PROGRESS.  (Bug#13546)
+
 2013-02-13  Glenn Morris  <rgm@gnu.org>
 
        * keyboard.c (input-decode-map, key-translation-map): Doc fixes.
index 8024031..214fb7f 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -6209,6 +6209,7 @@ sys_pipe (int * phandles)
        {
          _close (phandles[0]);
          _close (phandles[1]);
+         errno = EMFILE;
          rc = -1;
        }
       else
@@ -6281,19 +6282,31 @@ _sys_read_ahead (int fd)
 
       /* Configure timeouts for blocking read.  */
       if (!GetCommTimeouts (hnd, &ct))
-       return STATUS_READ_ERROR;
+       {
+         cp->status = STATUS_READ_ERROR;
+         return STATUS_READ_ERROR;
+       }
       ct.ReadIntervalTimeout           = 0;
       ct.ReadTotalTimeoutMultiplier    = 0;
       ct.ReadTotalTimeoutConstant      = 0;
       if (!SetCommTimeouts (hnd, &ct))
-       return STATUS_READ_ERROR;
+       {
+         cp->status = STATUS_READ_ERROR;
+         return STATUS_READ_ERROR;
+       }
 
       if (!ReadFile (hnd, &cp->chr, sizeof (char), (DWORD*) &rc, ovl))
        {
          if (GetLastError () != ERROR_IO_PENDING)
-           return STATUS_READ_ERROR;
+           {
+             cp->status = STATUS_READ_ERROR;
+             return STATUS_READ_ERROR;
+           }
          if (!GetOverlappedResult (hnd, ovl, (DWORD*) &rc, TRUE))
-           return STATUS_READ_ERROR;
+           {
+             cp->status = STATUS_READ_ERROR;
+             return STATUS_READ_ERROR;
+           }
        }
     }
   else if (fd_info[fd].flags & FILE_SOCKET)