summaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-28 08:56:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-28 08:56:25 +0000
commitb9cd4e6d4728e1b0a0c53f2d076b4cb69e5895c6 (patch)
treea71c6549e851777cfd880a842c993be2f35ea6cb /win32
parent55c157da550407d4792900ba1d831b129f474153 (diff)
downloadruby-b9cd4e6d4728e1b0a0c53f2d076b4cb69e5895c6.tar.gz
ruby-b9cd4e6d4728e1b0a0c53f2d076b4cb69e5895c6.tar.xz
ruby-b9cd4e6d4728e1b0a0c53f2d076b4cb69e5895c6.zip
* win32/win32.c (kill): negate pid under Win9x.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/win32/win32.c b/win32/win32.c
index e9edfdfc1..dec014c38 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;