diff --git a/connectd/connectd.c b/connectd/connectd.c index f3c1e1605..367253f03 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -10,6 +10,7 @@ #include "config.h" #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -569,7 +571,6 @@ static struct io_plan *websocket_connection_in(struct io_conn *conn, goto close_execfail_fail; if (childpid == 0) { - size_t max; close(childmsg[0]); close(execfail[0]); @@ -582,9 +583,7 @@ static struct io_plan *websocket_connection_in(struct io_conn *conn, goto child_errno_fail; /* Make (fairly!) sure all other fds are closed. */ - max = sysconf(_SC_OPEN_MAX); - for (size_t i = STDERR_FILENO + 1; i < max; i++) - close(i); + closefrom(STDERR_FILENO + 1); /* Tell websocket helper what we read so far. */ execlp(daemon->websocket_helper, daemon->websocket_helper, @@ -2117,6 +2116,10 @@ int main(int argc, char *argv[]) * our status_ and failed messages. */ status_setup_async(daemon->master); + /* Don't leave around websocketd zombies. Technically not portable, + * but OK for Linux and BSD, so... */ + signal(SIGCHLD, SIG_IGN); + /* This streams gossip to and from gossipd */ daemon->gossipd = daemon_conn_new(daemon, GOSSIPCTL_FD, recv_gossip, NULL,