summaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-12 06:47:24 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-12 06:47:24 +0000
commit5a132429d7d3a769f4505aa2b793b6a39a224c1b (patch)
treec1b772cb4a90c762e4d5c39856b715cb6106cb93 /win32
parent443e356406f9e39140c8c0b795dbb2c8243467d3 (diff)
downloadruby-5a132429d7d3a769f4505aa2b793b6a39a224c1b.tar.gz
ruby-5a132429d7d3a769f4505aa2b793b6a39a224c1b.tar.xz
ruby-5a132429d7d3a769f4505aa2b793b6a39a224c1b.zip
* win32/win32.c (kill): add support of signal 9 on mswin32/mingw32.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 15a9a2a67..b67a094fe 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2559,18 +2559,36 @@ chown(const char *path, int owner, int group)
int
kill(int pid, int sig)
{
-#if 1
- if ((unsigned int)pid == GetCurrentProcessId())
- return raise(sig);
+ if ((unsigned int)pid == GetCurrentProcessId())
+ return raise(sig);
- if (sig == 2 && pid > 0)
- if (GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid))
- return 0;
+ if (sig == 2 && pid > 0) {
+ if (!GenerateConsoleCtrlEvent(CTRL_C_EVENT, (DWORD)pid)) {
+ errno = GetLastError();
+ return -1;
+ }
+ }
+ else if (sig == 9 && pid > 0) {
+ HANDLE hProc;
+ hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
+ if (hProc == NULL || hProc == INVALID_HANDLE_VALUE) {
+ errno = GetLastError();
+ return -1;
+ }
+ if (!TerminateProcess(hProc, 0)) {
+ errno = GetLastError();
+ CloseHandle(hProc);
+ return -1;
+ }
+ CloseHandle(hProc);
+ }
+ else {
+ errno = EINVAL;
return -1;
-#else
- return 0;
-#endif
+ }
+
+ return 0;
}
int