From: Jeff King <peff@peff.net>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?
Date: Tue, 10 Nov 2015 07:25:02 -0500 [thread overview]
Message-ID: <20151110122501.GA14418@sigill.intra.peff.net> (raw)
In-Reply-To: <CAM-tV--hBSdCJckCnMtKgkQB2f_3eN8sXHdFWwg2hzb6s7ufxw@mail.gmail.com>
On Mon, Nov 09, 2015 at 08:05:25PM -0500, Noam Postavsky wrote:
> > Automated tests would be nice, but I suspect it may be too complicated
> > to be worth it.
>
> I attempted
>
> test_ignore_sighup ()
> {
> mkdir "$HOME/.git-credential-cache" &&
> chmod 0700 "$HOME/.git-credential-cache" &&
> git -c credentialCache.ignoreSIGHUP=true credential-cache--daemon
> "$HOME/.git-credential-cache/socket" &
> kill -SIGHUP $! &&
> ps $!
> }
>
> test_expect_success 'credentialCache.ignoreSIGHUP works' 'test_ignore_sighup'
>
> but it does't pass (testing manually by running
> ./git-credential-cache--daemon $HOME/.git-credential-cache/test-socket
> & and then kill -HUP does work).
Your test looks racy. After the "&" in spawning the daemon, we don't
have any guarantee that the daemon actually reached the signal() call
before we issued our kill.
The daemon issues an "ok\n" to stdout to report that it's ready to serve
(this is how the auto-spawn avoids races). So you could use that with a
fifo to fix this. It's a little complicated; see lib-git-daemon.sh for
an example.
I'm also not sure the use of "ps" here is portable (i.e., does it always
report a useful error code on all systems?).
So I dunno. Given the complexity of the test, and that it is such a
simple feature that is unlikely to be broken, I'm not sure it is worth
it. A test failure seems like it would more likely be a problem in the
test, not the code.
> From 5fc95b6e2f956403da6845fc3ced83b21bee7bb0 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs@users.sourceforge.net>
> Date: Mon, 9 Nov 2015 19:26:29 -0500
> Subject: [PATCH] credential-cache: new option to ignore sighup
>
> Introduce new option "credentialCache.ignoreSIGHUP" which stops
> git-credential-cache--daemon from quitting on SIGHUP. This is useful
> when "git push" is started from Emacs, because all child
> processes (including the daemon) will receive a SIGHUP when "git push"
> exits.
> ---
Can you add a signed-off-by here (see the "sign-off" section in
Documentation/SubmittingPatches).
> diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
> index eef6fce..6cda9c0 100644
> --- a/credential-cache--daemon.c
> +++ b/credential-cache--daemon.c
> @@ -256,6 +256,9 @@ int main(int argc, const char **argv)
> OPT_END()
> };
>
> + int ignore_sighup = 0;
> + git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);
> +
Style-wise, I think the declaration should go above the options-list.
> @@ -264,6 +267,10 @@ int main(int argc, const char **argv)
>
> check_socket_directory(socket_path);
> register_tempfile(&socket_file, socket_path);
> +
> + if (ignore_sighup)
> + signal(SIGHUP, SIG_IGN);
> +
This part looks obviously correct. :)
I don't think there's any need to use sigchain_push here (we have no
intention of ever popping it).
-Peff
next prev parent reply other threads:[~2015-11-10 12:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 16:45 git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead? Noam Postavsky
2015-10-18 15:15 ` Noam Postavsky
2015-10-18 17:58 ` Junio C Hamano
2015-10-19 0:51 ` Noam Postavsky
2015-10-21 2:35 ` Noam Postavsky
2015-10-24 21:47 ` Noam Postavsky
2015-10-25 16:58 ` Junio C Hamano
2015-10-26 21:50 ` Jeff King
2015-10-27 0:50 ` Noam Postavsky
2015-10-27 18:41 ` Jeff King
2015-10-27 19:04 ` Junio C Hamano
2015-10-27 17:52 ` Junio C Hamano
2015-10-27 18:47 ` Jeff King
2015-10-28 3:46 ` Noam Postavsky
2015-10-30 0:10 ` Jeff King
2015-10-30 0:43 ` Noam Postavsky
2015-10-30 0:50 ` Jeff King
2015-10-30 1:20 ` Noam Postavsky
2015-10-30 21:08 ` Jeff King
2015-11-09 2:58 ` Noam Postavsky
2015-11-09 15:53 ` Jeff King
2015-11-10 1:05 ` Noam Postavsky
2015-11-10 12:25 ` Jeff King [this message]
2015-11-10 12:26 ` Jeff King
2015-11-11 0:22 ` Noam Postavsky
2015-12-04 18:55 ` Junio C Hamano
2015-12-04 19:06 ` Jeff King
2015-12-04 20:05 ` Junio C Hamano
2015-12-04 23:25 ` Jeff King
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=20151110122501.GA14418@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=npostavs@users.sourceforge.net \
/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).