Skip to content

Commit

Permalink
Windows: return UV_ESRCH from uv_kill
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed Nov 9, 2011
1 parent a378110 commit 2b7774a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/win/process.c
Expand Up @@ -1082,14 +1082,17 @@ static uv_err_t uv__kill(HANDLE process_handle, int signum) {
}
} else if (signum == 0) {
/* Health check: is the process still alive? */
if (GetExitCodeProcess(process_handle, &status) &&
status == STILL_ACTIVE) {
err = uv_ok_;
if (GetExitCodeProcess(process_handle, &status)) {
if (status == STILL_ACTIVE) {
err = uv_ok_;
} else {
err = uv__new_artificial_error(UV_ESRCH);
}
} else {
err = uv__new_sys_error(GetLastError());
}
} else {
err.code = UV_ENOSYS;
err = uv__new_artificial_error(UV_ENOSYS);
}

return err;
Expand Down Expand Up @@ -1122,8 +1125,12 @@ uv_err_t uv_kill(int pid, int signum) {
HANDLE process_handle = OpenProcess(PROCESS_TERMINATE |
PROCESS_QUERY_INFORMATION, FALSE, pid);

if (process_handle == INVALID_HANDLE_VALUE) {
return uv__new_sys_error(GetLastError());
if (process_handle == NULL) {
if (GetLastError() == ERROR_INVALID_PARAMETER) {
return uv__new_artificial_error(UV_ESRCH);
} else {
return uv__new_sys_error(GetLastError());
}
}

err = uv__kill(process_handle, signum);
Expand Down

0 comments on commit 2b7774a

Please sign in to comment.