1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

Ladybird: Close the other side's file descriptors after forking

When spawning a WebContent process, we have to close the file
descriptors belonging to the "other side" in both processes, or they
will not get naturally "cleaned up" when one of the processes exits.

Fixes #93
This commit is contained in:
Andreas Kling 2022-10-08 11:01:59 +02:00 committed by Andrew Kaster
parent 7362755f30
commit 52a7282c64

View file

@ -563,6 +563,9 @@ void WebContentView::create_client()
auto child_pid = fork();
if (!child_pid) {
MUST(Core::System::close(ui_fd_passing_fd));
MUST(Core::System::close(ui_fd));
auto takeover_string = String::formatted("x:{}", wc_fd);
MUST(Core::System::setenv("SOCKET_TAKEOVER"sv, takeover_string, true));
@ -577,6 +580,9 @@ void WebContentView::create_client()
VERIFY_NOT_REACHED();
}
MUST(Core::System::close(wc_fd_passing_fd));
MUST(Core::System::close(wc_fd));
auto socket = MUST(Core::Stream::LocalSocket::adopt_fd(ui_fd));
MUST(socket->set_blocking(true));