git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>,
	phillip.wood@dunelm.org.uk
Cc: "Carlo Marcelo Arenas Belón via GitGitGadget"
	<gitgitgadget@gmail.com>,
	git@vger.kernel.org, "Chris Torek" <chris.torek@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH v3 2/4] compat/mingw: allow sigaction(SIGCHLD)
Date: Wed, 9 Jul 2025 15:13:06 +0100	[thread overview]
Message-ID: <0931e1f2-6254-474f-be91-664cec9745f5@gmail.com> (raw)
In-Reply-To: <p6xegxqqq4wzi6gnokypy3k5auxk3d2wxmj4pj45ugfomace3q@y5q3e2al42oj>

On 26/06/2025 21:09, Carlo Marcelo Arenas Belón wrote:
> On Thu, Jun 26, 2025 at 04:19:11PM -0800, phillip.wood123@gmail.com wrote:
>> On 26/06/2025 15:58, Carlo Marcelo Arenas Belón wrote:
>>> On Thu, Jun 26, 2025 at 02:56:22PM -0800, Phillip Wood wrote:
>>>> On 26/06/2025 14:15, Carlo Marcelo Arenas Belón wrote:
>>>>> On Thu, Jun 26, 2025 at 01:52:47PM -0800, Phillip Wood wrote:
>>>>>> On 26/06/2025 09:53, Carlo Marcelo Arenas Belón via GitGitGadget wrote:
>>>>>>> From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= <carenas@gmail.com>
>>>>>>>
>>>>>>> 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.
>>>>>>
>>>>>> Why are we returning -1 below instead of SIG_ERR if we want the behavior to
>>>>>> match?
>>>>>
>>>>> By "match", I mean that in both cases we will get an error return value
>>>>> and errno won't be set to EINVAL (which is what POSIX requires)
>>>>>
>>>>> In our codebase since we ignore the return code anyway, it wouldn't make
>>>>> a difference, either way.
>>>>>
>>>>> signal() returns a pointer, and sigaction() returns and int,
>>>>
>>>> Oh right, I'd forgotten they have different return types. I think we should
>>>> probably be setting errno = EINVAL before returning -1 to match what this
>>>> function does with other signals it does not support - just because our
>>>> current callers ignore the return value doesn't mean that future callers
>>>> will and they might want check errno if they see the function fail.
>>>
>>> I agree, and indeed had to triple check and change my implementation after I
>>> confirmed that signal(SIGCHLD) does not change errno on Windows (not our
>>> version, neither of the windows libc or mingw, even if it is documented[1] to
>>> do so.
>>>
>>> It might be because the signal number itself is bogus (there is none for
>>> SIGCHLD in their headers, and git uses their own numbers in compat), but
>>> either way, I would rather be consistent with signal() at least originally.
>>
>> I'm not sure I understand - don't we want the sigaction() wrapper to behave
>> like sigaction() would?
> 
> for at least the first iteration, I would rather have sigaction() behave
> like signal(), so that the change doesn't introduce any regressions.

What regressions are you worried about? We're talking about changing a 
single call from signal() to sigaction(). I'd have thought we're far 
more likely to introduce regressions if we change the behavior of the 
windows implementation of sigaction() to behave like signal() as that 
introduces more variation between different platforms.

> eventually, sigaction() should behave like any other sigaction(), but to
> do so, I suspect the windows emulation might need to change their SIGCHLD
> to match.
> 
> just confirmed with MSVC that if I use 20 instead of 17, errno gets updated
> just like the documentation says it should.

Oh not so setting errno as you want to do would not actually match 
signal() on Windows in that case?

Thanks

Phillip

> Carlo
> 
> PS. Maybe we should get dscho involved?
>>>
>>> [1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/signal


  reply	other threads:[~2025-07-09 14:13 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 [this message]
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=0931e1f2-6254-474f-be91-664cec9745f5@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=carenas@gmail.com \
    --cc=chris.torek@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).