Re: [PATCH 2/3] daemon: use sigaction() to install child_handler()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 24, 2025 at 09:20:22AM -0800, Junio C Hamano wrote:
> "Carlo Marcelo Arenas Belón via GitGitGadget"
> <gitgitgadget@xxxxxxxxx> writes:
> 
> > From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@xxxxxxxxx>
> >
> > In a future change, the flags used for processing SIGCHLD will need to
> > be updated, which is only possible by using sigaction().
> >
> > Replace the call, which hs the added benefit of using BSD semantics
> > reliably and therefore not needing the rearming call.
> >
> > Signed-off-by: Carlo Marcelo Arenas Belón <carenas@xxxxxxxxx>
> > ---
> >  daemon.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> Hmph.  Wouldn't it a much smaller change and fix to discard 2/3 and
> most of the 3/3 and instead make a siginterrupt() call to tell the
> system to interrupt us when SIGCHLD is received only on platforms
> where siginterrupt() is available?  Use of sigaction() does not seem
> to be buying us anything for the purpose of this series.

Using siginterrupt() would work (at least it did when I tested it in
OpenBSD), but its use is discouraged as it has been obsoleted by the
last two versions of POSIX (since 2018).

Indeed that code fails to build[1] in recent Linux with :

  daemon.c: In function ‘service_loop’:
  daemon.c:1138:17: error: ‘siginterrupt’ is deprecated: Use sigaction with SA_RESTART instead [-Werror=deprecated-declarations]
   1138 |                 siginterrupt(SIGCHLD, 1);
        |                 ^~~~~~~~~~~~
  In file included from compat/posix.h:112,
                   from git-compat-util.h:26,
                   from daemon.c:3:
  /usr/include/signal.h:324:12: note: declared here
    324 | extern int siginterrupt (int __sig, int __interrupt) __THROW
        |            ^~~~~~~~~~~~

Most systems seem to be implementing `signal()` with `sigaction()`
nowadays, but in the ones that are not (ex: Solaris) calling the later
to get a `struct sigaction` with the flags being used, doesn't work
and therefore it would seem, that the only way to do this reliably is
by using sigaction everywhere for this signal, as implemented in 2/3.

Carlo

[1] https://github.com/git/git/actions/runs/15849572148




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux