aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-07-21 09:14:28 -0700
committerJunio C Hamano <gitster@pobox.com>2025-07-21 09:14:28 -0700
commitd80b7640b12496f86eb534460c7edfe1a5f1d79e (patch)
treeaa1ac4653eb1d3d7fb5a42333518381e59c2770d
parentfe02fe75fcfea2f487284f4507c3d86760d71805 (diff)
parentd83e1eef3bbf8cd85ce5ffc4afff3fbdfb006fd1 (diff)
downloadgit-d80b7640b12496f86eb534460c7edfe1a5f1d79e.tar.gz
Merge branch 'cb/daemon-reap-children'
Futz with SIGCHLD handling in "git daemon". * cb/daemon-reap-children: daemon: use sigaction() to install child_handler() compat/mingw: allow sigaction(SIGCHLD)
-rw-r--r--compat/mingw-posix.h1
-rw-r--r--compat/mingw.c4
-rw-r--r--daemon.c12
3 files changed, 11 insertions, 6 deletions
diff --git a/compat/mingw-posix.h b/compat/mingw-posix.h
index 88e0cf9292..631a208684 100644
--- a/compat/mingw-posix.h
+++ b/compat/mingw-posix.h
@@ -96,6 +96,7 @@ struct sigaction {
unsigned sa_flags;
};
#define SA_RESTART 0
+#define SA_NOCLDSTOP 1
struct itimerval {
struct timeval it_value, it_interval;
diff --git a/compat/mingw.c b/compat/mingw.c
index 8a9972a1ca..5d69ae32f4 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -2561,7 +2561,9 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
int sigaction(int sig, struct sigaction *in, struct sigaction *out)
{
- if (sig != SIGALRM)
+ if (sig == SIGCHLD)
+ return -1;
+ else if (sig != SIGALRM)
return errno = EINVAL,
error("sigaction only implemented for SIGALRM");
if (out)
diff --git a/daemon.c b/daemon.c
index 61cd50f720..1f3e23b6a8 100644
--- a/daemon.c
+++ b/daemon.c
@@ -915,11 +915,9 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
static void child_handler(int signo UNUSED)
{
/*
- * Otherwise empty handler because systemcalls will get interrupted
- * upon signal receipt
- * SysV needs the handler to be rearmed
+ * Otherwise empty handler because systemcalls should get interrupted
+ * upon signal receipt.
*/
- signal(SIGCHLD, child_handler);
}
static int set_reuse_addr(int sockfd)
@@ -1115,6 +1113,7 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
static int service_loop(struct socketlist *socklist)
{
+ struct sigaction sa;
struct pollfd *pfd;
CALLOC_ARRAY(pfd, socklist->nr);
@@ -1124,7 +1123,10 @@ static int service_loop(struct socketlist *socklist)
pfd[i].events = POLLIN;
}
- signal(SIGCHLD, child_handler);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_NOCLDSTOP;
+ sa.sa_handler = child_handler;
+ sigaction(SIGCHLD, &sa, NULL);
for (;;) {
check_dead_children();