mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:57:34 +00:00
LibIPC: Make sure FDs survive when passed into a MessageBuffer
This commit is contained in:
parent
cc6db526a6
commit
de9b454f89
3 changed files with 34 additions and 4 deletions
|
@ -148,7 +148,16 @@ Encoder& Encoder::operator<<(const Dictionary& dictionary)
|
|||
|
||||
Encoder& Encoder::operator<<(const File& file)
|
||||
{
|
||||
m_buffer.fds.append(file.fd());
|
||||
int fd = file.fd();
|
||||
if (fd != -1) {
|
||||
auto result = dup(fd);
|
||||
if (result < 0) {
|
||||
perror("dup");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
fd = result;
|
||||
}
|
||||
m_buffer.fds.append(adopt_ref(*new AutoCloseFileDescriptor(fd)));
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue