mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
Kernel: Fix overly eager fd closing in sys$execve()
When obeying FD_CLOEXEC, we don't need to explicitly call close() on all the FileDescriptions. We can just clear them out from the process fd table. ~FileDescription() will call close() anyway. This fixes an issue where TelnetServer would shut down accepted sockets when exec'ing a shell for them. Since the parent process still has the socket open, we should not force-close it. Just let go.
This commit is contained in:
parent
0930e2323b
commit
b058852c62
|
@ -245,11 +245,8 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
|
|||
|
||||
for (size_t i = 0; i < m_fds.size(); ++i) {
|
||||
auto& description_and_flags = m_fds[i];
|
||||
if (description_and_flags.description() && description_and_flags.flags() & FD_CLOEXEC) {
|
||||
// FIXME: Should this error path be observed somehow?
|
||||
(void)description_and_flags.description()->close();
|
||||
if (description_and_flags.description() && description_and_flags.flags() & FD_CLOEXEC)
|
||||
description_and_flags = {};
|
||||
}
|
||||
}
|
||||
|
||||
new_main_thread = nullptr;
|
||||
|
|
Loading…
Reference in a new issue