[lxc-devel] [lxc/master] utils: close parent end in child process after fork
0x0916 on Github
lxc-bot at linuxcontainers.org
Sat Jul 8 05:30:41 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 343 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170708/5a704ea0/attachment.bin>
-------------- next part --------------
From 6e670321612ef146d3c5706fc760738dca47c8ad Mon Sep 17 00:00:00 2001
From: Long Wang <w at laoqinren.net>
Date: Sat, 8 Jul 2017 13:27:16 +0800
Subject: [PATCH] utils: close parent end in child process after fork
Signed-off-by: Long Wang <w at laoqinren.net>
---
src/lxc/utils.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index e21985373..81f6987aa 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -490,6 +490,9 @@ extern struct lxc_popen_FILE *lxc_popen(const char *command)
/* child */
int child_std_end = STDOUT_FILENO;
+ close(parent_end);
+ parent_end = -1;
+
if (child_end != child_std_end) {
/* dup2() doesn't dup close-on-exec flag */
dup2(child_end, child_std_end);
More information about the lxc-devel
mailing list