diff --git a/src/main.c b/src/main.c index 062a4862..7a7c20ac 100644 --- a/src/main.c +++ b/src/main.c @@ -615,7 +615,9 @@ int main(int argc, char *argv[]) { ev_io_start(main_loop, ipc_io); } - /* Also handle the UNIX domain sockets passed via socket activation */ + /* Also handle the UNIX domain sockets passed via socket activation. The + * parameter 1 means "remove the environment variables", we don’t want to + * pass these to child processes. */ int fds = sd_listen_fds(1); if (fds < 0) ELOG("socket activation: Error in sd_listen_fds\n"); diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index f6872fb6..36560a8d 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -63,8 +63,11 @@ sub activate_i3 { # We are about to exec, but we did not modify $^F to include $socket # when creating the socket (because the file descriptor could have a - # number != 3 which would lead to i3 leaking a file descriptor). - # Therefore, we explicitly have to clear the file descriptor flags now: + # number != 3 which would lead to i3 leaking a file descriptor). This + # caused Perl to set the FD_CLOEXEC flag, which would close $socket on + # exec(), effectively *NOT* passing $socket to the new process. + # Therefore, we explicitly clear FD_CLOEXEC (the only flag right now) + # by setting the flags to 0. POSIX::fcntl($socket, F_SETFD, 0) or die "Could not clear fd flags: $!"; # If the socket does not use file descriptor 3 by chance already, we