mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* win32/win32.c (kill): fix typo and add signal 0 support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f5a6a36471
commit
277d89447a
2 changed files with 30 additions and 6 deletions
|
@ -2540,10 +2540,30 @@ kill(int pid, int sig)
|
|||
}
|
||||
|
||||
if (IsWin95()) pid = -pid;
|
||||
if ((unsigned int)pid == GetCurrentProcessId() && sig != SIGKILL)
|
||||
if ((unsigned int)pid == GetCurrentProcessId() &&
|
||||
(sig != 0 && sig != SIGKILL))
|
||||
return raise(sig);
|
||||
|
||||
switch (sig) {
|
||||
case 0:
|
||||
RUBY_CRITICAL({
|
||||
HANDLE hProc =
|
||||
OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, (DWORD)pid);
|
||||
if (hProc == NULL || hProc == INVALID_HANDLE_VALUE) {
|
||||
if (GetLastError() == ERROR_INVALID_PARAMETER) {
|
||||
errno = ESRCH;
|
||||
}
|
||||
else {
|
||||
errno = EPERM;
|
||||
}
|
||||
ret = -1;
|
||||
}
|
||||
else {
|
||||
CloseHandle(hProc);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case SIGINT:
|
||||
RUBY_CRITICAL({
|
||||
if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) {
|
||||
|
@ -2576,7 +2596,7 @@ kill(int pid, int sig)
|
|||
});
|
||||
break;
|
||||
|
||||
define:
|
||||
default:
|
||||
errno = EINVAL;
|
||||
ret = -1;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue