mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
Basic ^C interrupt implementation.
For testing, I made cat put itself into a new process group. This should eventually be done by sh between fork() and exec().
This commit is contained in:
parent
621217ffeb
commit
10b666f69a
11 changed files with 94 additions and 38 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "TTY.h"
|
||||
#include "Process.h"
|
||||
|
||||
TTY::TTY(unsigned major, unsigned minor)
|
||||
: CharacterDevice(major, minor)
|
||||
|
@ -38,3 +39,16 @@ void TTY::emit(byte ch)
|
|||
{
|
||||
m_buffer.append(ch);
|
||||
}
|
||||
|
||||
void TTY::interrupt()
|
||||
{
|
||||
dbgprintf("%s: Interrupt ^C pressed!\n", ttyName().characters());
|
||||
if (pgid()) {
|
||||
dbgprintf("%s: Send SIGINT to everyone in pgrp %d\n", ttyName().characters(), pgid());
|
||||
InterruptDisabler disabler;
|
||||
Process::for_each_in_pgrp(pgid(), [this] (auto& process) {
|
||||
dbgprintf("%s: Send SIGINT to %d\n", ttyName().characters(), process.pid());
|
||||
process.send_signal(SIGINT, nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue