From dfb4dde7630d6c5cc18401cb7c0798704ef6f157 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/lws-plat-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/plat/lws-plat-unix.c b/lib/plat/lws-plat-unix.c index bacc6af64..aebc22f21 100644 --- a/lib/plat/lws-plat-unix.c +++ b/lib/plat/lws-plat-unix.c @@ -330,6 +330,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;