Skip to content

Commit c76a98e

Browse files
committed
Report success when Windows kill() emulation signals an exiting process.
This is consistent with the POSIX verdict that kill() shall not report ESRCH for a zombie process. Back-patch to 9.0 (all supported versions). Test code from commit d7cdf6e depends on it, and log messages about kill() reporting "Invalid argument" will cease to appear for this not-unexpected condition.
1 parent 48aa003 commit c76a98e

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

src/port/kill.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,28 @@ pgkill(int pid, int sig)
5050
return 0;
5151
}
5252

53-
if (GetLastError() == ERROR_FILE_NOT_FOUND)
54-
errno = ESRCH;
55-
else if (GetLastError() == ERROR_ACCESS_DENIED)
56-
errno = EPERM;
57-
else
58-
errno = EINVAL;
59-
return -1;
53+
switch (GetLastError())
54+
{
55+
case ERROR_BROKEN_PIPE:
56+
case ERROR_BAD_PIPE:
57+
58+
/*
59+
* These arise transiently as a process is exiting. Treat them
60+
* like POSIX treats a zombie process, reporting success.
61+
*/
62+
return 0;
63+
64+
case ERROR_FILE_NOT_FOUND:
65+
/* pipe fully gone, so treat the process as gone */
66+
errno = ESRCH;
67+
return -1;
68+
case ERROR_ACCESS_DENIED:
69+
errno = EPERM;
70+
return -1;
71+
default:
72+
errno = EINVAL; /* unexpected */
73+
return -1;
74+
}
6075
}
6176

6277
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy