mingw: add kill emulation
This is a quite limited kill-emulation; it can only handle SIGTERM on positive pids. However, it's enough for git-daemon. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Erik Faye-Lund committed
Nov 4, 2010 at 02:35 UTC
82fc07b7baa6f9e188025cc06a87ebc60a6f2d5e
2 files changed
+22
compat/mingw.c
+19
@@ -936,6 +936,25 @@ void mingw_execv(const char *cmd, char *const *argv)
936
mingw_execve(cmd, argv, environ);
937
}
938
939
+int mingw_kill(pid_t pid, int sig)
940
+{
941
+ if (pid > 0 && sig == SIGTERM) {
942
+ HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
943
+
944
+ if (TerminateProcess(h, -1)) {
945
+ CloseHandle(h);
946
+ return 0;
947
+ }
948
+
949
+ errno = err_win_to_posix(GetLastError());
950
+ CloseHandle(h);
951
+ return -1;
952
+ }
953
+
954
+ errno = EINVAL;
955
+ return -1;
956
+}
957
+
958
static char **copy_environ(void)
959
{
960
char **env;
compat/mingw.h
+3
@@ -143,6 +143,9 @@ static inline int mingw_unlink(const char *pathname)
143
#define WNOHANG 1
144
pid_t waitpid(pid_t pid, int *status, unsigned options);
145
146
+#define kill mingw_kill
147
+int mingw_kill(pid_t pid, int sig);
148
+
149
#ifndef NO_OPENSSL
150
#include <openssl/ssl.h>
151
static inline int mingw_SSL_set_fd(SSL *ssl, int fd)