1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:48:12 +00:00

Deallocate PTY's when they close.

This required a fair bit of plumbing. The CharacterDevice::close() virtual
will now be closed by ~FileDescriptor(), allowing device implementations to
do custom cleanup at that point.

One big problem remains: if the master PTY is closed before the slave PTY,
we go into crashy land.
This commit is contained in:
Andreas Kling 2019-01-30 18:26:19 +01:00
parent 027d26cd5d
commit b4e478aa50
19 changed files with 104 additions and 12 deletions

View file

@ -735,7 +735,7 @@ void Process::sys$exit(int status)
kprintf("sys$exit: %s(%u) exit with status %d\n", name().characters(), pid(), status);
#endif
set_state(Dead);
die();
m_termination_status = status;
m_termination_signal = 0;
@ -750,7 +750,7 @@ void Process::terminate_due_to_signal(byte signal)
dbgprintf("terminate_due_to_signal %s(%u) <- %u\n", name().characters(), pid(), signal);
m_termination_status = 0;
m_termination_signal = signal;
set_state(Dead);
die();
}
void Process::send_signal(byte signal, Process* sender)
@ -935,8 +935,8 @@ void Process::crash()
ASSERT_INTERRUPTS_DISABLED();
ASSERT(state() != Dead);
m_termination_signal = SIGSEGV;
set_state(Dead);
dumpRegions();
die();
Scheduler::pick_next_and_switch_now();
ASSERT_NOT_REACHED();
}
@ -2130,3 +2130,9 @@ int Process::sys$chmod(const char* pathname, mode_t mode)
return error;
return 0;
}
void Process::die()
{
set_state(Dead);
m_fds.clear();
}