Skip to content

Commit

Permalink
mingw: add kill emulation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Erik Faye-Lund authored and Junio C Hamano committed Nov 4, 2010
1 parent ef7108c commit 82fc07b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
19 changes: 19 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,25 @@ void mingw_execv(const char *cmd, char *const *argv)
mingw_execve(cmd, argv, environ);
}

int mingw_kill(pid_t pid, int sig)
{
if (pid > 0 && sig == SIGTERM) {
HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);

if (TerminateProcess(h, -1)) {
CloseHandle(h);
return 0;
}

errno = err_win_to_posix(GetLastError());
CloseHandle(h);
return -1;
}

errno = EINVAL;
return -1;
}

static char **copy_environ(void)
{
char **env;
Expand Down
3 changes: 3 additions & 0 deletions compat/mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static inline int mingw_unlink(const char *pathname)
#define WNOHANG 1
pid_t waitpid(pid_t pid, int *status, unsigned options);

#define kill mingw_kill
int mingw_kill(pid_t pid, int sig);

#ifndef NO_OPENSSL
#include <openssl/ssl.h>
static inline int mingw_SSL_set_fd(SSL *ssl, int fd)
Expand Down

0 comments on commit 82fc07b

Please sign in to comment.