From 60ffc5b6cb85e6fc7707f6b1d918c93b77a92f2c Mon Sep 17 00:00:00 2001 From: David Gibson Date: Tue, 23 Aug 2022 16:31:51 +1000 Subject: Don't unnecessarily avoid CLOEXEC flags There are several places in the passt code where we have lint overrides because we're not adding CLOEXEC flags to open or other operations. Comments suggest this is because it's before we fork() into the background but we'll need those file descriptors after we're in the background. However, as the name suggests CLOEXEC closes on exec(), not on fork(). The only place we exec() is either super early invoke the avx2 version of the binary, or when we start a shell in pasta mode, which certainly *doesn't* require the fds in question. Add the CLOEXEC flag in those places, and remove the lint overrides. Signed-off-by: David Gibson --- pasta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pasta.c') diff --git a/pasta.c b/pasta.c index 5a78065..830748f 100644 --- a/pasta.c +++ b/pasta.c @@ -223,7 +223,7 @@ void pasta_ns_conf(struct ctx *c) */ int pasta_netns_quit_init(struct ctx *c) { - int flags = O_NONBLOCK | (c->foreground ? O_CLOEXEC : 0); + int flags = O_NONBLOCK | O_CLOEXEC; struct epoll_event ev = { .events = EPOLLIN }; int inotify_fd; -- cgit v1.2.3