From: "Carlo Marcelo Arenas Belón via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
"Chris Torek" <chris.torek@gmail.com>,
"Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH v2 1/3] compat/posix.h: track SA_RESTART fallback
Date: Wed, 25 Jun 2025 07:35:26 +0000 [thread overview]
Message-ID: <e82b7425bbc2540fa5ef3fd4584e6f902485d064.1750836928.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2002.v2.git.git.1750836928.gitgitgadget@gmail.com>
From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
Systems without SA_RESTART are using custom CFLAGS or headers
instead of the standard header file.
Correct that, and invent a Makefile variable to track the
exceptions which will become handy in the next commits.
Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
Makefile | 6 ++++++
compat/mingw-posix.h | 1 -
compat/posix.h | 8 ++++++++
config.mak.uname | 7 ++++---
configure.ac | 17 +++++++++++++++++
meson.build | 4 ++++
6 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 70d1543b6b86..c4e6fc7bfd13 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,9 @@ include shared.mak
# when attempting to read from an fopen'ed directory (or even to fopen
# it at all).
#
+# Define USE_NON_POSIX_SIGNAL if don't have support for SA_RESTART or
+# prefer to use ANSI C signal() over POSIX sigaction()
+#
# Define OPEN_RETURNS_EINTR if your open() system call may return EINTR
# when a signal is received (as opposed to restarting).
#
@@ -1811,6 +1814,9 @@ ifdef FREAD_READS_DIRECTORIES
COMPAT_CFLAGS += -DFREAD_READS_DIRECTORIES
COMPAT_OBJS += compat/fopen.o
endif
+ifdef USE_NON_POSIX_SIGNAL
+ COMPAT_CFLAGS += -DUSE_NON_POSIX_SIGNAL
+endif
ifdef OPEN_RETURNS_EINTR
COMPAT_CFLAGS += -DOPEN_RETURNS_EINTR
endif
diff --git a/compat/mingw-posix.h b/compat/mingw-posix.h
index 88e0cf92924b..a0dca756d104 100644
--- a/compat/mingw-posix.h
+++ b/compat/mingw-posix.h
@@ -95,7 +95,6 @@ struct sigaction {
sig_handler_t sa_handler;
unsigned sa_flags;
};
-#define SA_RESTART 0
struct itimerval {
struct timeval it_value, it_interval;
diff --git a/compat/posix.h b/compat/posix.h
index 067a00f33b83..84ad2c9647aa 100644
--- a/compat/posix.h
+++ b/compat/posix.h
@@ -250,6 +250,14 @@ char *gitdirname(char *);
#define NAME_MAX 255
#endif
+/*
+ * On most systems <signal.h> would have given us this, but
+ * not on some systems (e.g. NonStop, QNX).
+ */
+#ifndef SA_RESTART
+# define SA_RESTART 0 /* disabled for sigaction() */
+#endif
+
typedef uintmax_t timestamp_t;
#define PRItime PRIuMAX
#define parse_timestamp strtoumax
diff --git a/config.mak.uname b/config.mak.uname
index b1c5c4d5e8ed..1914982eb13e 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -486,6 +486,7 @@ ifeq ($(uname_S),Windows)
NO_STRTOUMAX = YesPlease
NO_MKDTEMP = YesPlease
NO_INTTYPES_H = YesPlease
+ USE_NON_POSIX_SIGNAL = YesPlease
CSPRNG_METHOD = rtlgenrandom
# VS2015 with UCRT claims that snprintf and friends are C99 compliant,
# so we don't need this:
@@ -654,8 +655,6 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
FREAD_READS_DIRECTORIES = UnfortunatelyYes
# Not detected (nor checked for) by './configure'.
- # We don't have SA_RESTART on NonStop, unfortunalety.
- COMPAT_CFLAGS += -DSA_RESTART=0
# Apparently needed in compat/fnmatch/fnmatch.c.
COMPAT_CFLAGS += -DHAVE_STRING_H=1
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
@@ -664,6 +663,7 @@ ifeq ($(uname_S),NONSTOP_KERNEL)
NO_MMAP = YesPlease
NO_POLL = YesPlease
NO_INTPTR_T = UnfortunatelyYes
+ USE_NON_POSIX_SIGNAL = UnfortunatelyYes
CSPRNG_METHOD = openssl
SANE_TOOL_PATH = /usr/coreutils/bin:/usr/local/bin
SHELL_PATH = /usr/coreutils/bin/bash
@@ -699,6 +699,7 @@ ifeq ($(uname_S),MINGW)
NEEDS_LIBICONV = YesPlease
NO_STRTOUMAX = YesPlease
NO_MKDTEMP = YesPlease
+ USE_NON_POSIX_SIGNAL = YesPlease
NO_SVN_TESTS = YesPlease
# The builtin FSMonitor requires Named Pipes and Threads on Windows.
@@ -782,7 +783,6 @@ ifeq ($(uname_S),MINGW)
endif
endif
ifeq ($(uname_S),QNX)
- COMPAT_CFLAGS += -DSA_RESTART=0
EXPAT_NEEDS_XMLPARSE_H = YesPlease
HAVE_STRINGS_H = YesPlease
NEEDS_SOCKET = YesPlease
@@ -794,4 +794,5 @@ ifeq ($(uname_S),QNX)
NO_PTHREADS = YesPlease
NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease
+ USE_NON_POSIX_SIGNAL = UnfortunatelyYes
endif
diff --git a/configure.ac b/configure.ac
index f6caab919a3e..8c52fd129f31 100644
--- a/configure.ac
+++ b/configure.ac
@@ -862,6 +862,23 @@ fi
GIT_CONF_SUBST([ICONV_OMITS_BOM])
fi
+# Define USE_NON_POSIX_SIGNAL if don't have support for SA_RESTART or
+# prefer using ANSI C signal() over POSIX sigaction()
+
+AC_CACHE_CHECK([whether SA_RESTART is supported], [ac_cv_siginterrupt], [
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([#include <signal.h>], [[
+ #ifdef SA_RESTART
+ #endif
+ siginterrupt(SIGCHLD, 1)
+ ]])],[ac_cv_siginterrupt=yes],[
+ ac_cv_siginterrupt=no
+ USE_NON_POSIX_SIGNAL=UnfortunatelyYes
+ ]
+ )
+])
+GIT_CONF_SUBST([USE_NON_POSIX_SIGNAL])
+
## Checks for typedefs, structures, and compiler characteristics.
AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
#
diff --git a/meson.build b/meson.build
index 7fea4a34d684..f27c37e430ae 100644
--- a/meson.build
+++ b/meson.build
@@ -1094,6 +1094,10 @@ else
build_options_config.set('NO_EXPAT', '1')
endif
+if compiler.get_define('SA_RESTART', prefix: '#include <signal.h>') == ''
+ libgit_c_args += '-DUSE_NON_POSIX_SIGNAL'
+endif
+
if not compiler.has_header('sys/select.h')
libgit_c_args += '-DNO_SYS_SELECT_H'
endif
--
gitgitgadget
next prev parent reply other threads:[~2025-06-25 7:35 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 14:08 [PATCH 0/3] daemon: explicitly allow EINTR during poll() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-24 14:08 ` [PATCH 1/3] compat/posix.h: track SA_RESTART fallback Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-24 15:34 ` Junio C Hamano
2025-06-24 16:28 ` Junio C Hamano
2025-06-24 14:08 ` [PATCH 2/3] daemon: use sigaction() to install child_handler() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-24 15:37 ` Junio C Hamano
2025-06-24 22:29 ` Carlo Marcelo Arenas Belón
2025-06-24 23:27 ` Chris Torek
2025-06-24 16:20 ` Junio C Hamano
2025-06-24 21:28 ` Carlo Marcelo Arenas Belón
2025-06-24 21:32 ` Junio C Hamano
2025-06-24 14:08 ` [PATCH 3/3] daemon: explicitly allow EINTR during poll() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-24 14:33 ` Carlo Marcelo Arenas Belón
2025-06-24 15:43 ` Junio C Hamano
2025-06-25 7:35 ` [PATCH v2 0/3] " Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-25 7:35 ` Carlo Marcelo Arenas Belón via GitGitGadget [this message]
2025-06-25 16:07 ` [PATCH v2 1/3] compat/posix.h: track SA_RESTART fallback Junio C Hamano
2025-06-25 22:24 ` Carlo Marcelo Arenas Belón
2025-06-26 0:33 ` Junio C Hamano
2025-06-26 1:35 ` Carlo Marcelo Arenas Belón
2025-06-26 0:45 ` Junio C Hamano
2025-06-25 7:35 ` [PATCH v2 2/3] daemon: use sigaction() to install child_handler() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-25 16:06 ` Junio C Hamano
2025-06-25 16:22 ` Junio C Hamano
2025-06-25 7:35 ` [PATCH v2 3/3] daemon: explicitly allow EINTR during poll() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-25 16:11 ` Junio C Hamano
2025-06-25 8:39 ` [PATCH v2 0/3] " Phillip Wood
2025-06-25 16:24 ` Junio C Hamano
2025-06-25 19:35 ` Phillip Wood
2025-06-26 18:24 ` [RFC PATCH] daemon: add a self pipe to trigger reaping of children Carlo Marcelo Arenas Belón
2025-06-26 21:22 ` [RFC PATCH 0/2] daemon: tracking childs without signals Carlo Marcelo Arenas Belón
2025-06-26 21:22 ` [RFC PATCH 1/2] run-command: add a pipe() write end to childs Carlo Marcelo Arenas Belón
2025-06-26 21:22 ` [RFC PATCH 2/2] daemon: poor man's pidfd like POC Carlo Marcelo Arenas Belón
2025-06-27 8:38 ` [RFC PATCH] daemon: add a self pipe to trigger reaping of children Phillip Wood
2025-06-28 6:19 ` Carlo Marcelo Arenas Belón
2025-07-01 13:38 ` Phillip Wood
2025-06-30 15:16 ` Junio C Hamano
2025-06-25 16:07 ` [PATCH v2 0/3] daemon: explicitly allow EINTR during poll() Junio C Hamano
2025-06-26 8:50 ` Carlo Marcelo Arenas Belón
2025-06-26 8:53 ` [PATCH v3 0/4] " Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-26 8:53 ` [PATCH v3 1/4] compat/posix.h: track SA_RESTART fallback Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-27 1:41 ` Junio C Hamano
2025-06-26 8:53 ` [PATCH v3 2/4] compat/mingw: allow sigaction(SIGCHLD) Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-26 12:52 ` Phillip Wood
2025-06-26 13:15 ` Carlo Marcelo Arenas Belón
2025-06-26 13:56 ` Phillip Wood
2025-06-26 14:58 ` Carlo Marcelo Arenas Belón
2025-06-26 15:19 ` phillip.wood123
2025-06-26 20:09 ` Carlo Marcelo Arenas Belón
2025-07-09 14:13 ` Phillip Wood
2025-07-09 16:36 ` Carlo Marcelo Arenas Belón
2025-06-26 8:53 ` [PATCH v3 3/4] daemon: use sigaction() to install child_handler() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-26 13:11 ` Phillip Wood
2025-06-26 15:33 ` Junio C Hamano
2025-06-26 16:36 ` Carlo Marcelo Arenas Belón
2025-06-26 18:04 ` Phillip Wood
2025-07-07 22:14 ` Junio C Hamano
2025-06-26 8:53 ` [PATCH v3 4/4] daemon: explicitly allow EINTR during poll() Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-26 13:14 ` Phillip Wood
2025-07-09 14:12 ` [PATCH v3 0/4] " Phillip Wood
2025-07-09 17:04 ` Carlo Marcelo Arenas Belón
2025-07-10 19:45 ` [PATCH v4 0/2] " Carlo Marcelo Arenas Belón via GitGitGadget
2025-07-10 19:45 ` [PATCH v4 1/2] compat/mingw: allow sigaction(SIGCHLD) Carlo Marcelo Arenas Belón via GitGitGadget
2025-07-10 21:38 ` Eric Sunshine
2025-07-10 19:45 ` [PATCH v4 2/2] daemon: use sigaction() to install child_handler() Carlo Marcelo Arenas Belón via GitGitGadget
2025-07-10 21:26 ` [PATCH v4 0/2] daemon: explicitly allow EINTR during poll() Junio C Hamano
2025-07-10 23:18 ` Carlo Arenas
2025-07-11 13:14 ` Phillip Wood
2025-07-14 21:52 ` Junio C Hamano
2025-07-15 9:29 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e82b7425bbc2540fa5ef3fd4584e6f902485d064.1750836928.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=carenas@gmail.com \
--cc=chris.torek@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).