fd32a52002ab68770b95f9affaec9b2520fa45b0
[git-annex.git] /
1 [[!comment format=mdwn
2  username="joey"
3  subject="""comment 2"""
4  date="2020-11-17T16:06:53Z"
5  content="""
6 The ssh process you run this way has the following file descriptor:
7
8         l-wx------ 1 joey joey 64 Nov 17 12:07 2 -> pipe:[6320144]
9
10 That pipe is connected to git-annex. git-annex is waiting to read any errors
11 that the special remote might output to stderr, in order to relay them to the
12 user. Yes, this was changed by the referenced commit.
13
14 Since git-annex has already waited on the process, the process is dead
15 by the point it waits on the stderr relayer thread. The only purpose
16 of waiting rather than closing the handle is to see anything the process
17 might have output in its dying breath.
18
19 Also, this is very similar to the problem fixed
20 in [[!commit aa492bc65904a19f22ffdfc20d7a5e7052e2f54d]] and in
21 [[!commit cb74cefde782e542ad609b194792deabe55b1f5a]], also involving ssh.
22 Those were solved using a rather ugly up to 2 second wait for any late
23 stderr to arrive, though it only delays when the handle is kept open like this.
24
25 There are surely a ton of places where this could potentially happen.
26 Not only stderr.. it's entirely possible that process that git-annex
27 expects to read stdout from might spawn a daemon that keeps inherited
28 stdout open, and exit, leaving git-annex waiting forever to read
29 from the pipe.
30
31 I'm doubtful this is a bug everywhere that git-annex reads all the stdout from
32 a pipe. Because it seems to me a great many programs would have the same
33 problem if a program they were piping stdout from behaved in that way. 
34 I've never seen anything concern itself with this potential problem. This is
35 why proper daemons close their handles, certianly their stdout handle. stderr
36 is a slightly special case maybe.
37
38 processTranscript is one example of another place in git-annex that
39 waits to consume all stderr from a process and would be hung by such a daemon.
40 There are a dozen in all,
41 `git grep 'std_err =' | egrep 'CreatePipe|UseHandle | grep -v nullh`
42 I suppose they could all be audited and maybe something abstracted out to
43 deal with them all.
44 """]]