-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git media client will hang when using ssh to access repositories #117
Comments
The problem is that We'll need to modify the command execution to not provide buffers for |
This is actually a little bit more involved. This is only triggered when the credential cache daemon is not already running. If it is not running, |
With a little more investigation, this seems like it might be a bug in git itself. Things work like this: The In git's credential-cache.c where it launches the credential cache daemon, you can see that it requests to not keep stdout open. I think it also should ask to not keep stderr open, as such: diff --git a/credential-cache.c b/credential-cache.c
index 9a03792..9abce0b 100644
--- a/credential-cache.c
+++ b/credential-cache.c
@@ -47,7 +47,9 @@ static void spawn_daemon(const char *socket)
argv[1] = socket;
daemon.argv = argv;
daemon.no_stdin = 1;
+ daemon.no_stderr = 1;
daemon.out = -1;
if (start_command(&daemon))
die_errno("unable to start cache daemon"); If I do this, the problem goes away. @github/git - does this seem like a legit git bug to you? We'll have to work around this anyway by just never waiting on the subprocess's stderr, but if it is a legit git bug we might want to send patches. Edit the code should not set |
Hrm. I'd question a bit whether it is actually worth capturing stderr from a But assuming we did want to close stderr, this is definitely the wrong place to do it. Most of the interesting errors would happen while the daemon is starting up, and they would all go to diff --git a/credential-cache--daemon.c b/credential-cache--daemon.c
index 3b370ca..1a5572c 100644
--- a/credential-cache--daemon.c
+++ b/credential-cache--daemon.c
@@ -211,6 +211,7 @@ static void serve_cache(const char *socket_path)
printf("ok\n");
fclose(stdout);
+ fclose(stderr);
while (serve_cache_loop(fd))
; /* nothing */ That at least allows through messages related to opening the socket. We'd still miss errors and warnings that happen when serving individual clients, though. Two things that would make it a little better:
Of the two, I think I prefer the first. But I'd still be curious to hear why you want to pipe stderr in the first place. |
Thanks for taking a look at this @peff, I think the reason we were capturing stderr is because the git media client may not necessarily be started from a terminal, and we'd want to bubble those errors up to whatever is controlling it. However, the stderr that we're really expecting to read from I think would come from the git process itself, not the cache daemon. This problem only shows up in the case where this The reason I think the code in git has a problem is that I think a daemon should not assume that it has a terminal to write to. Given how this daemon is started from the git process, it could be safe-ish to assume that there is a terminal to write startup errors to, but once it's launched that terminal can go away at any time and the output won't go anywhere (or if some later terminal opens up on the same device it could get the output, and that'd be weird). I suppose the credential cache daemon is not your typical daemon in that it's usually started by the git process, is generally short lived, and probably has a terminal to write to. With regard to start up errors, you're correct, my patch does prevent them from showing while your patch lets them through. I verified this by chmod'ing I think for now, we will work around the problem by not piping stderr, as you suggest. I think we should be OK with that given the types of errors that might happen at that point. It may be that in the typical use case for the git / cache daemon interaction, allowing the daemon to assume it can write to the terminal is OK, I just wanted to check with some git internals experts to make sure that was the case 😄 |
Yeah, the "bubble up to GUI" thing makes sense. Git-media aside, this could be a problem even for something like GitHub for Mac making a call to I just sent a patch to the list. |
Steps to reproduce:
Use the
cache
credential helpergit config --global credental.helper cache
Clone a git media repository via ssh. You will then be prompted for github credentials and the git media client will hang:
The text was updated successfully, but these errors were encountered: