diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2013-08-14 21:04:31 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-08-15 12:30:51 +0200 |
commit | 993b8f2f8a0e3683e6ade93f81e294a9b0899517 (patch) | |
tree | bac8ba1107a87920cc44e5dbdf45c6fac8685995 | |
parent | ba0cb9c1ecc72e6b726deaf91193d24b2a85814a (diff) | |
download | unitd-993b8f2f8a0e3683e6ade93f81e294a9b0899517.tar unitd-993b8f2f8a0e3683e6ade93f81e294a9b0899517.zip |
hotplug: terminate uloop after fork(), redirect stdin, out and err to /dev/null
-rw-r--r-- | hotplug.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -124,7 +124,7 @@ static void handle_exec(struct blob_attr *msg, struct blob_attr *data) { char *argv[8]; struct blob_attr *cur; - int rem; + int rem, fd; int i = 0; blobmsg_for_each_attr(cur, msg, rem) @@ -138,9 +138,14 @@ static void handle_exec(struct blob_attr *msg, struct blob_attr *data) } if (debug < 2) { - close(STDIN_FILENO); - close(STDOUT_FILENO); - close(STDERR_FILENO); + fd = open("/dev/null", O_RDWR); + if (fd > -1) { + dup2(fd, STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + if (fd > STDERR_FILENO) + close(fd); + } } if (i > 0) { @@ -263,6 +268,7 @@ static void queue_next(void) queue_proc.pid = fork(); if (!queue_proc.pid) { + uloop_done(); c->handler(c->msg, c->data); exit(0); } |