зеркало из https://github.com/github/ruby.git
* 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:
Родитель
1fc2d3e4a9
Коммит
b76263fa09
|
@ -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>
|
||||
|
||||
* parse.y (opt_call_args): allow trailing comma after assoc
|
||||
|
|
|
@ -3847,7 +3847,14 @@ kill(int pid, int sig)
|
|||
|
||||
case SIGKILL:
|
||||
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 (GetLastError() == ERROR_INVALID_PARAMETER) {
|
||||
errno = ESRCH;
|
||||
|
@ -3858,11 +3865,24 @@ kill(int pid, int sig)
|
|||
ret = -1;
|
||||
}
|
||||
else {
|
||||
if (!TerminateProcess(hProc, 0)) {
|
||||
errno = EPERM;
|
||||
DWORD status;
|
||||
if (!GetExitCodeProcess(hProc, &status)) {
|
||||
errno = map_errno(GetLastError());
|
||||
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;
|
||||
|
@ -5629,6 +5649,11 @@ wunlink(const WCHAR *path)
|
|||
SetFileAttributesW(path, attr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (GetFileAttributesW(path) != (DWORD)-1 || GetLastError() != ERROR_FILE_NOT_FOUND) {
|
||||
Sleep(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче