From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Anthony Sottile <asottile@umich.edu>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: git does not wait on hook exes (^C)
Date: Fri, 21 Feb 2020 01:11:38 +0000 [thread overview]
Message-ID: <20200221011138.GB6462@camp.crustytoothpaste.net> (raw)
In-Reply-To: <CA+dzEBkP==U7iS=6vS4=g7LYwh_cKzqbPApDraiYv7tiwPOVHA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1741 bytes --]
On 2020-02-21 at 00:12:18, Anthony Sottile wrote:
> On Thu, Feb 20, 2020 at 4:01 PM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> > I believe the way that SIGINT works on a terminal is that it sends the
> > signal to all processes in the foreground process group. So my guess of
> > what's happening here is that Git and your script both get SIGINT, Git
> > cleans up and exits quickly, leaving your script running.
> >
> > If so, I'm not sure that Git can do much here. If Git waited for the
> > hook to exit, then a broken or hung hook would cause Git to hang
> > indefinitely, which is not what the user intended when they pressed
> > Ctrl-C. Usually what the user wants is an immediate return to the
> > terminal in such a case, and I think most users would consider it a bug
> > if Git were to wait for its children.
>
> Taking git out of the situation:
>
> Create a shell script:
>
> ```bash
> #!/usr/bin/env bash
> .git/hooks/pre-commit
> ```
>
> ```console
> $ ./t.sh
> zzz part 1
> ^Czzz part 2
> exiting
> $
> ```
>
> that works fine (and is the expected case for `subprocess` calls for
> example in python)
Yeah, I think this is the case I was discussing up above, where the
parent process waits for the subprocess to exit. If I modify the foo
function in your hook to also have a "sleep 10", then the parent process
hangs until the child process exits, which again would mean that Git
would hang indefinitely if the hook hung.
Can you maybe tell us a little more about your use case? What are you
doing in your hook that makes this case come up? Why is your hook
trapping SIGINT?
--
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]
next prev parent reply other threads:[~2020-02-21 1:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 21:14 git does not wait on hook exes (^C) Anthony Sottile
2020-02-21 0:01 ` brian m. carlson
2020-02-21 0:12 ` Anthony Sottile
2020-02-21 1:11 ` brian m. carlson [this message]
2020-02-21 1:20 ` Anthony Sottile
2020-02-21 2:25 ` brian m. carlson
2020-02-21 5:32 ` Jeff King
2020-02-21 6:08 ` Anthony Sottile
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=20200221011138.GB6462@camp.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=asottile@umich.edu \
--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).