git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH v4 0/2] daemon: explicitly allow EINTR during poll()
Date: Thu, 10 Jul 2025 19:45:41 +0000	[thread overview]
Message-ID: <pull.2002.v4.git.git.1752176743.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2002.v3.git.git.1750927988.gitgitgadget@gmail.com>

This series addresses and ambiguity that is at least visible in OpenBSD,
where zombie proceses would only be cleared after a new connection is
received.

The underlying problem is that when this code was originally introduced,
SA_RESTART was not widely implemented, and the signal() call usually
implemented SysV like semantics, at least until it started being
reimplemented by calling sigaction() internally.

Changes since v3

 * Remove patches 1 and 4 as suggested by Phillip, and setup the signal
   without SA_RESTART instead.

Changes since v2

 * Add a new patch 2 that modifies windows' sigaction so there is no more
   need for a fallback
 * Hopefully no more silly mistakes and a variable that finally makes sense

Changes since v1

 * Almost all references to siginterrupt has been removed and a better named
   variable used instead
 * Changes had been abstracted to minimize ifdefs and their introduction
   staged more naturally

Carlo Marcelo Arenas Belón (2):
  compat/mingw: allow sigaction(SIGCHLD)
  daemon: use sigaction() to install child_handler()

 compat/mingw-posix.h |  1 +
 compat/mingw.c       |  4 +++-
 daemon.c             | 12 +++++++-----
 3 files changed, 11 insertions(+), 6 deletions(-)


base-commit: cb3b40381e1d5ee32dde96521ad7cfd68eb308a6
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2002%2Fcarenas%2Fsiginterrupt-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2002/carenas/siginterrupt-v4
Pull-Request: https://github.com/git/git/pull/2002

Range-diff vs v3:

 1:  ae1ca6bb2b2 < -:  ----------- compat/posix.h: track SA_RESTART fallback
 2:  3f63479119f ! 1:  f21e8ff5c9d compat/mingw: allow sigaction(SIGCHLD)
     @@ Commit message
          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
     +    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 Cygwinr; note that
     +    the sigacgtion() 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>
      
       ## compat/mingw-posix.h ##
      @@ compat/mingw-posix.h: struct sigaction {
     - 	sig_handler_t sa_handler;
       	unsigned sa_flags;
       };
     + #define SA_RESTART 0
      +#define SA_NOCLDSTOP 1
       
       struct itimerval {
 3:  c66bda461f4 ! 2:  81c41b43e60 daemon: use sigaction() to install child_handler()
     @@ Metadata
       ## Commit message ##
          daemon: use sigaction() to install child_handler()
      
     -    In a future change, the flags used for processing SIGCHLD will need to
     -    be updated, which is only possible by using sigaction().
     +    Replace signal() with an equivalent invocation of sigaction(), but
     +    make sure to NOT set SA_RESTART so the original code that expects
     +    to be interrupted when children complete still works as designed.
      
     -    Replace signal() with an equivalent invocation of sigaction(), which
     -    has the added benefit of using BSD semantics reliably and therefore
     -    not needing the rearming call in the signal handler.
     +    This change has the added benefit of using BSD signal semantics reliably
     +    and therefore not needing the rearming call in the signal handler.
      
          Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
      
     @@ daemon.c: static int service_loop(struct socketlist *socklist)
       
      -	signal(SIGCHLD, child_handler);
      +	sigemptyset(&sa.sa_mask);
     -+	sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
     ++	sa.sa_flags = SA_NOCLDSTOP;
      +	sa.sa_handler = child_handler;
      +	sigaction(SIGCHLD, &sa, NULL);
       
 4:  851d663be0b < -:  ----------- daemon: explicitly allow EINTR during poll()

-- 
gitgitgadget

  parent reply	other threads:[~2025-07-10 19:45 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   ` [PATCH v2 1/3] compat/posix.h: track SA_RESTART fallback Carlo Marcelo Arenas Belón via GitGitGadget
2025-06-25 16:07     ` 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     ` Carlo Marcelo Arenas Belón via GitGitGadget [this message]
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=pull.2002.v4.git.git.1752176743.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=carenas@gmail.com \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood123@gmail.com \
    /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).