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

Re: git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?

From
Jeff King <peff@peff.net>
Date
Oct 26, 2015, 21:50 UTC
Message-ID
<20151026215016.GA17419@sigill.intra.peff.net>
In-Reply-To
<xmqqfv0ylwa7.fsf@gitster.mtv.corp.google.com>
On Sun, Oct 25, 2015 at 09:58:56AM -0700, Junio C Hamano wrote:
Show 24 quoted lines
> >>> I cannot speak for the person who was primarily responsible for
> >>> designing this behaviour, but I happen to agree with the current
> >>> behaviour in the situation where it was designed to be used.  Upon
> >>> the first use in your session, the "daemon" is auto-spawned, you can
> >>> keep talking with that same instance during your session, and you do
> >>> not have to do anything special to shut it down when you log out.
> >>> Isn't that what happens here?
> >>
> >> After looking at this some more, I've discovered this is NOT what
> >> actually happens here. If I "git push" from a shell and then log out
> >> and log in again, another "git push" does NOT ask me for a password.
> >> In other words, the daemon is NOT shut down automatically when I log
> >> out. Given that, does it make sense to change the daemon to ignore
> >> SIGHUP, or is there some way to change it so that it does exit on
> >> logout?
> 
> I have a feeling that it would be moving in a wrong direction to
> change the code to ignore HUP, as I do think "logout to shutdown"
> would be the desired behaviour.  If you are not seeing that happen,
> perhaps the first thing to do is to figure out why and fix the code
> so that it happens?
> 
> I dunno.  I'll cc Peff so that he can take a look when he comes
> back.
I could see it going both ways.

If SIGHUP means "I am logging out, my session is over", then I agree it makes sense to drop any credentials. And that is what SIGHUP meant when people logged in through hard-wired terminals.

But these days, people often have several simultaneous sessions open. They may have multiple ssh sessions to a single machine, or they may have a bunch of terminal windows open, each of which has a login shell and will send HUP to its children when it exits. In that case, you have a meta-session surrounding those individual terminal sessions, and you probably do want to keep the cache going as long as the meta session[1].

This is all further complicated by bash's huponexit option, which I think is off by default. So I, for example, have never noticed this behavior even with multiple xterms, because my cache never actually gets SIGHUP. I don't know what shell Noam is using, but I wonder if tweaking that option (or a similar one if not bash) might be helpful to signal "let this stuff keep running even after I exit".

But I am also not opposed to making it configurable somehow in git, if there really are two cases that cannot otherwise be distinguished.

-Peff
[1] Of course we have no idea when that meta-session is closed. But if
    you have a script that runs on X logout, for instance, you could put
    "git credential-cache exit" in it.
Previous: Junio C HamanoNext: Noam Postavsky
Message 8 of 29 in “git-credential-cache--daemon quits on SIGHUP, can we change it to ignore instead?”
  1. Noam PostavskyOct 10, 2015
  2. Noam PostavskyOct 18, 2015
  3. Junio C HamanoOct 18, 2015
  4. Noam PostavskyOct 19, 2015
  5. Noam PostavskyOct 21, 2015
  6. Noam PostavskyOct 24, 2015
  7. Junio C HamanoOct 25, 2015
  8. Jeff KingOct 26, 2015
  9. Noam PostavskyOct 27, 2015
  10. Jeff KingOct 27, 2015
  11. Junio C HamanoOct 27, 2015
  12. Junio C HamanoOct 27, 2015
  13. Jeff KingOct 27, 2015
  14. Noam PostavskyOct 28, 2015
  15. Jeff KingOct 30, 2015
  16. Noam PostavskyOct 30, 2015
  17. Jeff KingOct 30, 2015
  18. Noam PostavskyOct 30, 2015
  19. Jeff KingOct 30, 2015
  20. Noam PostavskyNov 9, 2015
  21. Jeff KingNov 9, 2015
  22. Noam PostavskyNov 10, 2015
  23. Jeff KingNov 10, 2015
  24. Jeff KingNov 10, 2015
  25. Noam PostavskyNov 11, 2015
  26. Junio C HamanoDec 4, 2015
  27. Jeff KingDec 4, 2015
  28. Junio C HamanoDec 4, 2015
  29. Jeff KingDec 4, 2015

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.