-
Notifications
You must be signed in to change notification settings - Fork 653
process: don't close stdio fds during spawn #1211
Comments
The problem here is unrelated to Closing the issue for now, but please let me know if it doesn't work for you and you are sure that it is a libuv problem. Thanks for reporting, though! |
Hi Fedor Thanks for looking into it. nodejs/node-v0.x-archive@e796e11 seems to be already merged under I added strace output to my testcase gist before and after #1083 that made me think this was the regression point. If you're just saying that never closing stdio is better solution to this problem then I totally agree. There are probably more problems that may come from this that I'm not aware of. Regarding your comment that this is a Node-only issue can you clarify what is wrong with the libuv testcase that doesn't pass under |
Hm... If I get you right, you are talking about following scenario:
Something like this or more complicated? |
If so - it should be fixed after fixing #1084 |
Yes, thats pretty much it. https://gist.github.com/tonistiigi/9721405#file-after-1083-L7 is the most likely cause imho. More complicated fd mapping support may very well solve this but note that in my case I do not care about the main process stdio fd-s at all. I just want a pipe to talk to the child process. Starting main process from a pipe that is already closed forbids me from doing that. Also just a reminder that this is only the case in |
Ah, I think I finally got what you was talking about :) Does this patch fix problem for you: diff --git a/src/unix/process.c b/src/unix/process.c
index 406df5f..0e4f44b 100644
--- a/src/unix/process.c
+++ b/src/unix/process.c
@@ -315,7 +315,7 @@ static void uv__process_child_init(uv_process_options_t options,
if (fd <= 2)
uv__nonblock(fd, 0);
- if (close_fd != -1)
+ if (close_fd != -1 && close_fd >= stdio_count)
close(close_fd);
}
|
Yes, that looks equal to 4240806 that worked for me. |
Ok, good. Mind submitting your patch with |
This is needed when closed stdio fd is reused for uv_spawn pipe. Fixes joyent#1211
Sure, here it is: #1217 |
This is needed when closed stdio fd is reused for uv_spawn pipe. Fixes joyent#1211
This is needed when closed stdio fd is reused for uv_spawn pipe. Fixes joyent#1211
This is needed when closed stdio fd is reused for uv_spawn pipe. Fixes joyent#1211
This is needed when closed stdio fd is reused for uv_spawn pipe. Fixes joyent#1211
It looks like this is causing a regression in the test suite:
While I can't reproduce it on any of my machines, it has been observed by Debian builders and your jenkins linux builder: |
Thanks, backported in c38e97e |
Original Node issue: nodejs/node-v0.x-archive#7331
Simpler testcase for the same issue: https://gist.github.com/tonistiigi/9721405
What is going on here(afaik) is that when stdio fd's are already closed during spawn then they are reused for creating pipes between the processes. Spawn doesn't handle this case, duplicates the pipe endpoint back to stdio and closes the old fd(effectively closing its own stdio).
The regression is at #1083.
One way to fix this would be to only close non-stdio fd's. Others will be closed automatically by
dup
. 4240806This does not happen in
v0.11
because 359d667 already forbids ever closing stdio. So the other way would be to get this underv0.10
as well.cc @indutny
The text was updated successfully, but these errors were encountered: