1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibIPC: Close received IPC::File fd's by default unless taken

When receiving a file descriptor over IPC, the receiver must now call
take_fd() on the IPC::File to take over the descriptor. Otherwise,
IPC::File will close the file on destruction.
This commit is contained in:
Andreas Kling 2021-01-14 09:31:21 +01:00
parent 384d047e3e
commit 7f2d8e8884
5 changed files with 50 additions and 5 deletions

View file

@ -78,7 +78,7 @@ static DefaultDocumentClient s_default_document_client;
void ClientConnection::handle(const Messages::LanguageServer::FileOpened& message)
{
auto file = Core::File::construct(this);
if (!file->open(message.file().fd(), Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
if (!file->open(message.file().take_fd(), Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
errno = file->error();
perror("open");
dbgln("Failed to open project file");