mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
LibCore: Implement System::set_close_on_exec
This commit is contained in:
parent
2e200489c8
commit
2abc792938
Notes:
github-actions[bot]
2025-03-20 02:26:29 +00:00
Author: https://github.com/stasoid
Commit: 2abc792938
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3002
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
8 changed files with 31 additions and 35 deletions
|
@ -11,25 +11,11 @@
|
|||
|
||||
namespace IPC {
|
||||
|
||||
// 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> File::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 {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<File> decode(Decoder& decoder)
|
||||
{
|
||||
auto file = TRY(decoder.files().try_dequeue());
|
||||
auto fd = file.fd();
|
||||
|
||||
auto fd_flags = TRY(Core::System::fcntl(fd, F_GETFD));
|
||||
TRY(Core::System::fcntl(fd, F_SETFD, fd_flags | FD_CLOEXEC));
|
||||
TRY(Core::System::set_close_on_exec(file.fd(), true));
|
||||
return file;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue