mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 04:52:23 +00:00
Ladybird+LibIPC: Move clearing FD_CLOEXEC helper logic to IPC::File
This commit is contained in:
parent
54f66c574c
commit
343a3a0d7e
Notes:
sideshowbarker
2024-07-16 20:31:50 +09:00
Author: https://github.com/ADKaster
Commit: 343a3a0d7e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/284
Reviewed-by: https://github.com/kalenikaliaksandr
Reviewed-by: https://github.com/trflynn89
2 changed files with 12 additions and 8 deletions
|
@ -160,14 +160,7 @@ ErrorOr<IPC::File> connect_new_request_server_client(Protocol::RequestClient& cl
|
|||
return Error::from_string_literal("Failed to connect to RequestServer");
|
||||
|
||||
auto socket = new_socket->take_client_socket();
|
||||
|
||||
// FIXME: IPC::Files transferred over the wire are always set O_CLOEXEC during decoding.
|
||||
// Perhaps we should add an option to IPC::File to allow the receiver to decide whether to
|
||||
// make it O_CLOEXEC or not. Or an attribute in the .ipc file?
|
||||
auto fd = socket.fd();
|
||||
auto fd_flags = MUST(Core::System::fcntl(fd, F_GETFD));
|
||||
fd_flags &= ~FD_CLOEXEC;
|
||||
MUST(Core::System::fcntl(fd, F_SETFD, fd_flags));
|
||||
TRY(socket.clear_close_on_exec());
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,17 @@ public:
|
|||
return exchange(m_fd, -1);
|
||||
}
|
||||
|
||||
// FIXME: IPC::Files transferred over the wire are always set O_CLOEXEC during decoding.
|
||||
// Perhaps we should add an option to IPC::File to allow the receiver to decide whether to
|
||||
// make it O_CLOEXEC or not. Or an attribute in the .ipc file?
|
||||
ErrorOr<void> clear_close_on_exec()
|
||||
{
|
||||
auto fd_flags = TRY(Core::System::fcntl(m_fd, F_GETFD));
|
||||
fd_flags &= ~FD_CLOEXEC;
|
||||
TRY(Core::System::fcntl(m_fd, F_SETFD, fd_flags));
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
explicit File(int fd)
|
||||
: m_fd(fd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue