mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
LibIPC: Make received file descriptors close-on-exec by default
I noticed that programs running in the terminal had an open file descriptor for the system theme buffer, inherited from the Terminal. Let's be nice and always mark incoming fds with FD_CLOEXEC.
This commit is contained in:
parent
2ed7f75e95
commit
05bb11f482
1 changed files with 5 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Dictionary.h>
|
||||
#include <LibIPC/File.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
@ -175,6 +176,10 @@ bool Decoder::decode([[maybe_unused]] File& file)
|
|||
dbgln("recvfd: {}", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
dbgln("fcntl(F_SETFD, FD_CLOEXEC)", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
file = File(fd, File::ConstructWithReceivedFileDescriptor);
|
||||
return true;
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue