aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-05-29 14:25:17 +0100
committerRon Yorston <rmy@pobox.com>2015-05-29 14:25:17 +0100
commit85ce92a584b8ca1a5c33828faf66ad304689e71f (patch)
treea36b290cf356830fcea455c08fa98a64afd98d5d
parent6fb17897d620572290b1f604430c06c261145aad (diff)
downloadbusybox-w32-85ce92a584b8ca1a5c33828faf66ad304689e71f.tar.gz
busybox-w32-85ce92a584b8ca1a5c33828faf66ad304689e71f.tar.bz2
busybox-w32-85ce92a584b8ca1a5c33828faf66ad304689e71f.zip
mingw: tidy up implementation of kill(2)
-rw-r--r--include/mingw.h2
-rw-r--r--win32/mingw.c2
-rw-r--r--win32/process.c22
3 files changed, 16 insertions, 10 deletions
diff --git a/include/mingw.h b/include/mingw.h
index bf8cd0c4c..7224ba50a 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -461,3 +461,5 @@ const char *get_busybox_exec_path(void);
461void init_winsock(void); 461void init_winsock(void);
462 462
463char *file_is_win32_executable(const char *p); 463char *file_is_win32_executable(const char *p);
464
465int err_win_to_posix(DWORD winerr);
diff --git a/win32/mingw.c b/win32/mingw.c
index bb08647a6..4ea18960e 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -24,7 +24,7 @@ unsigned int _CRT_fmode = _O_BINARY;
24 24
25smallint bb_got_signal; 25smallint bb_got_signal;
26 26
27static int err_win_to_posix(DWORD winerr) 27int err_win_to_posix(DWORD winerr)
28{ 28{
29 int error = ENOSYS; 29 int error = ENOSYS;
30 switch(winerr) { 30 switch(winerr) {
diff --git a/win32/process.c b/win32/process.c
index e9db5311e..318515375 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -376,15 +376,19 @@ int kill(pid_t pid, int sig)
376{ 376{
377 HANDLE h; 377 HANDLE h;
378 378
379 if (sig != SIGTERM) { 379 if (pid > 0 && sig == SIGTERM) {
380 bb_error_msg("kill only supports SIGTERM"); 380 if ((h=OpenProcess(PROCESS_TERMINATE, FALSE, pid)) != NULL &&
381 errno = EINVAL; 381 TerminateProcess(h, 0)) {
382 CloseHandle(h);
383 return 0;
384 }
385
386 errno = err_win_to_posix(GetLastError());
387 if (h != NULL)
388 CloseHandle(h);
382 return -1; 389 return -1;
383 } 390 }
384 h = OpenProcess(PROCESS_TERMINATE, FALSE, pid); 391
385 if (h == NULL) 392 errno = EINVAL;
386 return -1; 393 return -1;
387 if (TerminateProcess(h, 0) == 0)
388 return -1;
389 return 0;
390} 394}