From f7631b7a100ff70d250539d0916a79ac8b4dab9e Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Sat, 23 Jun 2018 05:44:36 +0800 Subject: [PATCH] sockets: FD_CLOEXEC If the user code forks, it inherits open copies of all lws sockets, which conflict if lws later decides to close them. --- lib/plat/unix/unix-sockets.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/plat/unix/unix-sockets.c b/lib/plat/unix/unix-sockets.c index a46990160..01bd32c21 100644 --- a/lib/plat/unix/unix-sockets.c +++ b/lib/plat/unix/unix-sockets.c @@ -74,6 +74,8 @@ lws_plat_set_socket_options(struct lws_vhost *vhost, int fd) struct protoent *tcp_proto; #endif + fcntl(fd, F_SETFD, FD_CLOEXEC); + if (vhost->ka_time) { /* enable keepalive on this socket */ optval = 1;