git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] rebase -i: ignore signals when forking subprocesses

From
Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Date
Sep 11, 2023, 10:32 UTC
Message-ID
<ZP7st70/G3kLujHG@ugly>
In-Reply-To
<a37a0f11-0723-4964-a187-54d960615d79@gmail.com>
On Mon, Sep 11, 2023 at 11:14:31AM +0100, Phillip Wood wrote:
Show 9 quoted lines
>On 11/09/2023 11:00, Phillip Wood wrote:
>> There is an inevitable race between wait() returning and calling 
>> signal() to restore the handlers for SIGINT and SIGQUIT,
>
>In principle if we installed a signal handler to set a flag if a signal 
>is received while calling wait() and then once wait() returns 
>successfully see if the child was killed we can tell if the signal was 
>received while the child was alive.
>
yes, this is what i was already writing:

my point is that you shouldn't be doing that in the first place. install the handlers when the sequencer is entered and leave them there. the handlers need to set (volatile) flag variables, which are checked by the sequencer on a regular basis.

a few notes on that:
- install without SA_RESTART, so syscalls can actually return with EINTR
   and give us the opportunity to check the flag.
- an alternative to setting flags is setjmp()/longjmp(), but you really
   don't want to go there.
- install with SA_RESETHAND, so the second ctrl-c will kill git
   regardless, providing an escape hatch.
>In practice if the child is catching SIGINT or SIGQUIT we cannot rely 
>on it re-raising the signal so that wont work.
>

yes, but that's a minor issue, i think. by far most hooks and other things that might be invoked within sequencer context don't mess with signals in the first place. the things that do should be presumed to do the right thing, which means at least a non-zero exit status in case of a premature termination, which will yield pretty much the same effect on our side anyway. so the only actually problematic situation would be us completely ignoring the exit code (like the git-gc call, but that's clearly a bug in git, and we control both sides, so it's easily fixable).

regards
Previous: Phillip WoodNext: Phillip Wood
Message 11 of 16 in “rebase -i: ignore signals when forking subprocesses”
  1. rebase -i: ignore signals when forking subprocessesPhillip Wood via GitGitGadget, Sep 7, 2023
  2. Johannes SchindelinSep 7, 2023
  3. Phillip WoodSep 8, 2023
  4. Johannes SchindelinSep 10, 2023
  5. Jeff KingSep 7, 2023
  6. Phillip WoodSep 8, 2023
  7. Phillip WoodSep 8, 2023
  8. Oswald BuddenhagenSep 10, 2023
  9. Phillip WoodSep 11, 2023
  10. Phillip WoodSep 11, 2023
  11. Oswald BuddenhagenSep 11, 2023
  12. Phillip WoodSep 13, 2023
  13. Oswald BuddenhagenSep 13, 2023
  14. Jeff KingSep 14, 2023
  15. Phillip WoodSep 14, 2023
  16. Junio C HamanoSep 7, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.