summaryrefslogtreecommitdiff
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
commit8790d9b76e103af734496fb85911daff9330cfa1 (patch)
treea71c6549e851777cfd880a842c993be2f35ea6cb /win32
parent0d0ae37e508788ea52e2e2cf477877ee58fa79dd (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
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 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;