mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
LibIPC: Add an expressive way to close an IPC::File after sending it
If you don't need a file descriptor after sending it to someone over IPC, construct it with IPC::File(fd, IPC::File::CloseAfterSending) and LibIPC will take care of it for you. :^)
This commit is contained in:
parent
7f2d8e8884
commit
f1f7bf567b
4 changed files with 3 additions and 7 deletions
|
@ -78,9 +78,7 @@ OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle
|
|||
auto id = download->id();
|
||||
auto fd = download->download_fd();
|
||||
m_downloads.set(id, move(download));
|
||||
auto response = make<Messages::ProtocolServer::StartDownloadResponse>(id, fd);
|
||||
response->on_destruction = [fd] { close(fd); };
|
||||
return response;
|
||||
return make<Messages::ProtocolServer::StartDownloadResponse>(id, IPC::File(fd, IPC::File::CloseAfterSending));
|
||||
}
|
||||
|
||||
OwnPtr<Messages::ProtocolServer::StopDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue