[PATCH 5/6] slip: Close and cloexec fds as appropriate
Ian Jackson
ijackson at chiark.greenend.org.uk
Mon Sep 22 16:45:12 BST 2014
Close unused pipe ends, and set cloexec in the parent on those that remain.
Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
slip.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/slip.c b/slip.c
index 38b2ca8..1286b5e 100644
--- a/slip.c
+++ b/slip.c
@@ -261,8 +261,11 @@ static void userv_entry(void *sst)
dup2(st->c_stdin[0],0);
dup2(st->c_stdout[1],1);
+ close(st->c_stdin[0]);
+ close(st->c_stdin[1]);
+ close(st->c_stdout[0]);
+ close(st->c_stdout[1]);
- /* XXX close all other fds */
setsid();
/* XXX We really should strdup() all of argv[] but because we'll just
exit anyway if execvp() fails it doesn't seem worth bothering. */
@@ -352,6 +355,8 @@ static void userv_invoke_userv(struct userv *st)
er, st, st->slip.nl.name);
close(er->c_stdin[0]);
close(er->c_stdout[1]);
+ setcloexec(er->c_stdin[1]);
+ setcloexec(er->c_stdout[0]);
free(er->argv);
free(addrs);
free(nets);
--
1.7.10.4
More information about the sgo-software-discuss
mailing list