Compare commits
No commits in common. "6f683c48f081f8009b560dfc3f3addabda0b6be7" and "24679e06ddf2c933593b9f00b53f0fe9df2aa573" have entirely different histories.
6f683c48f0
...
24679e06dd
@ -54,65 +54,16 @@ Result<u64> sys_kill(Registers*, SyscallArgs args)
|
|||||||
pid_t pid = (pid_t)args[0];
|
pid_t pid = (pid_t)args[0];
|
||||||
int signo = (int)args[1];
|
int signo = (int)args[1];
|
||||||
|
|
||||||
auto send_signal = [&](Thread* target) -> Result<void> {
|
// FIXME: Support this case.
|
||||||
if (current->auth.euid != 0 && current->auth.euid != target->auth.euid &&
|
if (pid <= 0) return err(ENOTSUP);
|
||||||
current->auth.egid != target->auth.egid)
|
|
||||||
return err(EPERM);
|
|
||||||
if (target->is_kernel) return {};
|
|
||||||
if (signo == 0) return {};
|
|
||||||
|
|
||||||
target->send_signal(signo);
|
auto* target = TRY(Result<Thread*>::from_option(Scheduler::find_by_pid(pid), ESRCH));
|
||||||
|
if (current->auth.euid != 0 && current->auth.euid != target->auth.euid && current->auth.egid != target->auth.egid)
|
||||||
|
return err(EPERM);
|
||||||
|
if (target->is_kernel) return 0;
|
||||||
|
if (signo == 0) return 0;
|
||||||
|
|
||||||
return {};
|
target->send_signal(signo);
|
||||||
};
|
|
||||||
|
|
||||||
if (pid > 0)
|
|
||||||
{
|
|
||||||
auto* target = TRY(Result<Thread*>::from_option(Scheduler::find_by_pid(pid), ESRCH));
|
|
||||||
TRY(send_signal(target));
|
|
||||||
}
|
|
||||||
else if (pid == 0)
|
|
||||||
{
|
|
||||||
int errno = -1;
|
|
||||||
bool pgid_exists = false;
|
|
||||||
Scheduler::for_each_in_process_group(current->pgid, [&](Thread* target) {
|
|
||||||
pgid_exists = true;
|
|
||||||
auto rc = send_signal(target);
|
|
||||||
if (rc.has_error())
|
|
||||||
{
|
|
||||||
errno = rc.error();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
if (errno > 0) return err(errno);
|
|
||||||
if (!pgid_exists) return err(ESRCH);
|
|
||||||
}
|
|
||||||
else if (pid == -1)
|
|
||||||
{
|
|
||||||
for (auto* thread : g_threads)
|
|
||||||
{
|
|
||||||
// We ignore permission errors here.
|
|
||||||
if (thread != current && thread->id != 1) send_signal(thread);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pid < -1)
|
|
||||||
{
|
|
||||||
int errno = -1;
|
|
||||||
bool pgid_exists = false;
|
|
||||||
Scheduler::for_each_in_process_group(-pid, [&](Thread* target) {
|
|
||||||
pgid_exists = true;
|
|
||||||
auto rc = send_signal(target);
|
|
||||||
if (rc.has_error())
|
|
||||||
{
|
|
||||||
errno = rc.error();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
if (errno > 0) return err(errno);
|
|
||||||
if (!pgid_exists) return err(ESRCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ void Thread::send_signal(int signo)
|
|||||||
check(signo > 0 && signo <= NSIG);
|
check(signo > 0 && signo <= NSIG);
|
||||||
pending_signals.set(signo - 1, true);
|
pending_signals.set(signo - 1, true);
|
||||||
|
|
||||||
if (state == ThreadState::Waiting || state == ThreadState::Sleeping || is_in_kernel(®s))
|
if (state == ThreadState::Waiting || state == ThreadState::Sleeping)
|
||||||
{
|
{
|
||||||
interrupted = true;
|
interrupted = true;
|
||||||
wake_up();
|
wake_up();
|
||||||
|
@ -135,9 +135,14 @@ Result<ui::EventResult> TerminalWidget::handle_key_event(const ui::KeyEventReque
|
|||||||
{
|
{
|
||||||
if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear();
|
if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear();
|
||||||
|
|
||||||
pid_t group = tcgetpgrp(m_pty);
|
// FIXME: Send SIGINT.
|
||||||
TRY(os::Process::kill(-group, SIGINT));
|
/*if (m_foreground_process_group.has_value())
|
||||||
|
{
|
||||||
|
Scheduler::for_each_in_process_group(m_foreground_process_group.value(), [](Thread* thread) {
|
||||||
|
thread->send_signal(SIGINT);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}*/
|
||||||
is_special_character = true;
|
is_special_character = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,9 +150,14 @@ Result<ui::EventResult> TerminalWidget::handle_key_event(const ui::KeyEventReque
|
|||||||
{
|
{
|
||||||
if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear();
|
if (!(m_settings.c_lflag & NOFLSH)) m_line_buffer.clear();
|
||||||
|
|
||||||
pid_t group = tcgetpgrp(m_pty);
|
// FIXME: Send SIGINT.
|
||||||
TRY(os::Process::kill(-group, SIGQUIT));
|
/*if (m_foreground_process_group.has_value())
|
||||||
|
{
|
||||||
|
Scheduler::for_each_in_process_group(m_foreground_process_group.value(), [](Thread* thread) {
|
||||||
|
thread->send_signal(SIGQUIT);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}*/
|
||||||
is_special_character = true;
|
is_special_character = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -588,5 +598,5 @@ void TerminalWidget::put_code_point(wchar_t c)
|
|||||||
|
|
||||||
void TerminalWidget::quit()
|
void TerminalWidget::quit()
|
||||||
{
|
{
|
||||||
kill(-tcgetpgrp(m_pty), SIGHUP);
|
kill(m_child_pid, SIGHUP);
|
||||||
}
|
}
|
||||||
|
@ -288,9 +288,9 @@ namespace wind::Keyboard
|
|||||||
else
|
else
|
||||||
letter = table[code];
|
letter = table[code];
|
||||||
if (_islower(letter)) letter = (char)_toupper(letter);
|
if (_islower(letter)) letter = (char)_toupper(letter);
|
||||||
if (_isupper(letter)) letter = letter - 0x40;
|
if (_isupper(letter)) letter = 0x40;
|
||||||
if (letter == '@') letter = letter - 0x40;
|
if (letter == '@') letter = 0x40;
|
||||||
if (letter > 'Z' && letter < '`') letter = letter - 0x40;
|
if (letter > 'Z' && letter < '`') letter = 0x40;
|
||||||
if (letter == '?') letter = 0x7f;
|
if (letter == '?') letter = 0x7f;
|
||||||
request.letter = letter;
|
request.letter = letter;
|
||||||
return request;
|
return request;
|
||||||
|
Loading…
Reference in New Issue
Block a user