diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-08-28 08:56:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-08-28 08:56:25 +0000 |
commit | 8790d9b76e103af734496fb85911daff9330cfa1 (patch) | |
tree | a71c6549e851777cfd880a842c993be2f35ea6cb | |
parent | 0d0ae37e508788ea52e2e2cf477877ee58fa79dd (diff) |
* win32/win32.c (kill): negate pid under Win9x.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | win32/win32.c | 27 |
2 files changed, 23 insertions, 9 deletions
@@ -1,3 +1,7 @@ +Wed Aug 28 17:45:03 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> + + * win32/win32.c (kill): negate pid under Win9x. + Wed Aug 28 16:36:40 2002 WATANABE Hirofumi <eban@ruby-lang.org> * configure.in (ar): don't check twice for ar. @@ -16,6 +20,7 @@ Wed Aug 28 15:00:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org> * string.c (rb_str_intern): ditto. +>>>>>>> 1.1095 Wed Aug 28 11:37:35 2002 NAKAMURA Usaku <usa@ruby-lang.org> * win32/win32.h: define SIGINT and SIGKILL if not defined. diff --git a/win32/win32.c b/win32/win32.c index e9edfdfc14..dec014c388 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2337,23 +2337,30 @@ kill(int pid, int sig) { int ret = 0; + if (pid <= 0) { + errno = EINVAL; + return -1; + } + + if (IsWin95()) pid = -pid; if ((unsigned int)pid == GetCurrentProcessId() && sig != SIGKILL) return raise(sig); - if (sig == SIGINT && pid > 0) { + switch (sig) { + case SIGINT: RUBY_CRITICAL({ if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) { - errno = GetLastError(); + if ((errno = GetLastError()) == 0) { + errno = EPERM; + } ret = -1; } }); - } - else if (sig == SIGKILL && pid > 0) { - HANDLE hProc; + break; + case SIGKILL: RUBY_CRITICAL({ - hProc = OpenProcess(PROCESS_TERMINATE, FALSE, - IsWin95() ? -pid : pid); + HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, (DWORD)pid); if (hProc == NULL || hProc == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_INVALID_PARAMETER) { errno = ESRCH; @@ -2369,10 +2376,12 @@ kill(int pid, int sig) } CloseHandle(hProc); }); - } - else { + break; + + define: errno = EINVAL; ret = -1; + break; } return ret; |