Unverified Commit f6aa6929 by Long Wang Committed by Stéphane Graber

utils: close parent end in child process after fork

Signed-off-by: 's avatarLong Wang <w@laoqinren.net>
parent dd75b97c
...@@ -490,6 +490,9 @@ extern struct lxc_popen_FILE *lxc_popen(const char *command) ...@@ -490,6 +490,9 @@ extern struct lxc_popen_FILE *lxc_popen(const char *command)
/* child */ /* child */
int child_std_end = STDOUT_FILENO; int child_std_end = STDOUT_FILENO;
close(parent_end);
parent_end = -1;
if (child_end != child_std_end) { if (child_end != child_std_end) {
/* dup2() doesn't dup close-on-exec flag */ /* dup2() doesn't dup close-on-exec flag */
dup2(child_end, child_std_end); dup2(child_end, child_std_end);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment