mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* win32/win32.c (kill): check the process exited or not before
teminationg it. [Bug #4943] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1fc2d3e4a9
commit
b76263fa09
2 changed files with 34 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Jul 7 00:40:16 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* win32/win32.c (kill): check the process exited or not before
|
||||||
|
teminationg it. [Bug #4943]
|
||||||
|
|
||||||
Wed Jul 6 23:13:19 2011 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed Jul 6 23:13:19 2011 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* parse.y (opt_call_args): allow trailing comma after assoc
|
* parse.y (opt_call_args): allow trailing comma after assoc
|
||||||
|
|
|
@ -3847,7 +3847,14 @@ kill(int pid, int sig)
|
||||||
|
|
||||||
case SIGKILL:
|
case SIGKILL:
|
||||||
RUBY_CRITICAL({
|
RUBY_CRITICAL({
|
||||||
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, (DWORD)pid);
|
HANDLE hProc;
|
||||||
|
struct ChildRecord* child = FindChildSlot(pid);
|
||||||
|
if (child) {
|
||||||
|
hProc = child->hProcess;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hProc = OpenProcess(PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION, FALSE, (DWORD)pid);
|
||||||
|
}
|
||||||
if (hProc == NULL || hProc == INVALID_HANDLE_VALUE) {
|
if (hProc == NULL || hProc == INVALID_HANDLE_VALUE) {
|
||||||
if (GetLastError() == ERROR_INVALID_PARAMETER) {
|
if (GetLastError() == ERROR_INVALID_PARAMETER) {
|
||||||
errno = ESRCH;
|
errno = ESRCH;
|
||||||
|
@ -3858,11 +3865,24 @@ kill(int pid, int sig)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!TerminateProcess(hProc, 0)) {
|
DWORD status;
|
||||||
errno = EPERM;
|
if (!GetExitCodeProcess(hProc, &status)) {
|
||||||
|
errno = map_errno(GetLastError());
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
CloseHandle(hProc);
|
else if (status == STILL_ACTIVE) {
|
||||||
|
if (!TerminateProcess(hProc, 0)) {
|
||||||
|
errno = EPERM;
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errno = ESRCH;
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
if (!child) {
|
||||||
|
CloseHandle(hProc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -5629,6 +5649,11 @@ wunlink(const WCHAR *path)
|
||||||
SetFileAttributesW(path, attr);
|
SetFileAttributesW(path, attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
while (GetFileAttributesW(path) != (DWORD)-1 || GetLastError() != ERROR_FILE_NOT_FOUND) {
|
||||||
|
Sleep(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue