LibCore: Implement System::set_close_on_exec

This commit is contained in:
stasoid 2025-02-13 18:50:23 +05:00 committed by Andrew Kaster
parent 2e200489c8
commit 2abc792938
Notes: github-actions[bot] 2025-03-20 02:26:29 +00:00
8 changed files with 31 additions and 35 deletions

View file

@ -269,4 +269,11 @@ ErrorOr<ByteString> current_executable_path()
return TRY(Process::get_name()).to_byte_string();
}
ErrorOr<void> set_close_on_exec(int handle, bool enabled)
{
if (!SetHandleInformation(to_handle(handle), HANDLE_FLAG_INHERIT, enabled ? 0 : HANDLE_FLAG_INHERIT))
return Error::from_windows_error();
return {};
}
}