From 507a5a689e7441782fcdbe96d88068dee9a3145e Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Wed, 15 Sep 2010 12:38:10 +1000 Subject: win32: process.c: implement kill(), SIGTERM only --- include/mingw.h | 2 +- win32/process.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/mingw.h b/include/mingw.h index 53a0a0d67..a43e8eca2 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -285,7 +285,7 @@ IMPL(getuid,int,1,void); int fcntl(int fd, int cmd, ...); #define fork() -1 IMPL(fsync,int,0,int fd UNUSED_PARAM); -NOIMPL(kill,pid_t pid UNUSED_PARAM, int sig UNUSED_PARAM); +int kill(pid_t pid, int sig); int link(const char *oldpath, const char *newpath); NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); int mingw_open (const char *filename, int oflags, ...); diff --git a/win32/process.c b/win32/process.c index 1b9b61878..cdd71182b 100644 --- a/win32/process.c +++ b/win32/process.c @@ -317,3 +317,20 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags) strncpy(sp->comm, pe.szExeFile, COMM_LEN); return sp; } + +int kill(pid_t pid, int sig) +{ + HANDLE h; + + if (sig != SIGTERM) { + bb_error_msg("kill only supports SIGTERM"); + errno = ENOSYS; + return -1; + } + h = OpenProcess(PROCESS_TERMINATE, FALSE, pid); + if (h == NULL) + return -1; + if (TerminateProcess(h, 0) == 0) + return -1; + return 0; +} -- cgit v1.2.3-55-g6feb