summaryrefslogtreecommitdiffstats
path: root/src/fastd.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-30 02:45:01 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-30 02:45:01 +0200
commit36f9d70182c4c2f2e617192ae34abd6c44549a78 (patch)
treebcc78e6b4cd4c24e0e702855bf8e87605490fcdd /src/fastd.c
parent9a86ce6ea990ac72337bffb78f663f8a904a408f (diff)
downloadfastd-36f9d70182c4c2f2e617192ae34abd6c44549a78.tar
fastd-36f9d70182c4c2f2e617192ae34abd6c44549a78.zip
shell: close all fds > 2 after forking
socket/fcntl to set FD_CLOEXEC isn't thread-safe with async verify handlers, and SOCK_CLOEXEC isn't portable.
Diffstat (limited to 'src/fastd.c')
-rw-r--r--src/fastd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fastd.c b/src/fastd.c
index 523889a..191c82d 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -378,7 +378,7 @@ static inline void maintenance(void) {
}
-static void close_fds(void) {
+void fastd_close_all_fds(void) {
struct rlimit rl;
int fd, maxfd;
@@ -465,7 +465,7 @@ static void drop_caps(void) {
fastd_cap_drop();
}
-/* will double fork and forward potential exit codes from the child to the parent */
+/* will double fork and wait for a status notification from the child */
static int daemonize(void) {
uint8_t status = 1;
int pipefd[2];
@@ -562,7 +562,7 @@ int main(int argc, char *argv[]) {
}
#endif
- close_fds();
+ fastd_close_all_fds();
fastd_random_bytes(&ctx.randseed, sizeof(ctx.randseed), false);