exec: close stdout and stderr streams on child signal
[project/rpcd.git] / exec.c
diff --git a/exec.c b/exec.c
index a5f6561..f7bfcb2 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1,7 +1,7 @@
 /*
  * rpcd - UBUS RPC server
  *
- *   Copyright (C) 2013 Jo-Philipp Wich <jow@openwrt.org>
+ *   Copyright (C) 2013-2014 Jo-Philipp Wich <jow@openwrt.org>
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -50,7 +50,7 @@ rpc_errno_status(void)
        }
 }
 
-static const char *
+const char *
 rpc_exec_lookup(const char *cmd)
 {
        struct stat s;
@@ -175,6 +175,12 @@ rpc_exec_process_cb(struct uloop_process *p, int stat)
 
        ustream_poll(&c->opipe.stream);
        ustream_poll(&c->epipe.stream);
+
+       close(c->opipe.fd.fd);
+       close(c->epipe.fd.fd);
+
+       ustream_poll(&c->opipe.stream);
+       ustream_poll(&c->epipe.stream);
 }
 
 static void