compat/mingw: allow sigaction(SIGCHLD)

A future change will start using sigaction to setup a SIGCHLD signal handler. The current code uses signal(), which returns SIG_ERR (but doesn't seem to set errno) so instruct sigaction() to do the same. A new SA flag will be needed, so copy the one from Cygwin; note that the sigaction() implementation that is provided won't use it, so its value is otherwise irrelevant. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlo Marcelo Arenas Belón committed Jul 10, 2025 at 19:45 UTC ef03aa432ab7fffa81a866ec21e08ecd8a876a26
2 files changed +4 -1
compat/mingw-posix.h
+1
@@ -96,6 +96,7 @@ struct sigaction {
96 unsigned sa_flags;
97 };
98 #define SA_RESTART 0
99 +#define SA_NOCLDSTOP 1
100
101 struct itimerval {
102 struct timeval it_value, it_interval;
compat/mingw.c
+3 -1
@@ -2561,7 +2561,9 @@ int setitimer(int type UNUSED, struct itimerval *in, struct itimerval *out)
2561
2562 int sigaction(int sig, struct sigaction *in, struct sigaction *out)
2563 {
2564 - if (sig != SIGALRM)
2564 + if (sig == SIGCHLD)
2565 + return -1;
2566 + else if (sig != SIGALRM)
2567 return errno = EINVAL,
2568 error("sigaction only implemented for SIGALRM");
2569 if (out)