fdpass_recv: Set O_CLOEXEC on received fds

Turns out this is necessary even if the fd is going to be passed through
exec() soon, because the supervisor might receive multiple fds before
spawning another process, in which case all of them are going to be
passed to the new process instead of just one.
This commit is contained in:
Yorhel 2025-03-24 11:07:36 +01:00
parent 9e1be5bc71
commit 2f50736782
3 changed files with 9 additions and 13 deletions

View file

@ -53,7 +53,7 @@ static int fufdpass_recv(pTHX_ I32 ax, int socket, size_t len) {
msg.msg_controllen = sizeof(cmsgbuf.buf);
msg.msg_flags = 0;
ssize_t r = recvmsg(socket, &msg, 0);
ssize_t r = recvmsg(socket, &msg, MSG_CMSG_CLOEXEC);
if (r < 0) {
ST(0) = &PL_sv_undef;
ST(1) = &PL_sv_undef;