1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:08:10 +00:00

UserspaceEmulator: Implement virt$sigprocmask

This commit is contained in:
Rummskartoffel 2022-01-28 15:12:22 +01:00 committed by Andreas Kling
parent 33b4b86141
commit 335183d0e9
2 changed files with 28 additions and 0 deletions

View file

@ -233,6 +233,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$shutdown(arg1, arg2);
case SC_sigaction:
return virt$sigaction(arg1, arg2, arg3);
case SC_sigprocmask:
return virt$sigprocmask(arg1, arg2, arg3);
case SC_sigreturn:
return virt$sigreturn();
case SC_socket:
@ -1365,6 +1367,31 @@ int Emulator::virt$sigaction(int signum, FlatPtr act, FlatPtr oldact)
return 0;
}
int Emulator::virt$sigprocmask(int how, FlatPtr set, FlatPtr old_set)
{
if (old_set) {
mmu().copy_to_vm(old_set, &m_signal_mask, sizeof(sigset_t));
}
if (set) {
sigset_t set_value;
mmu().copy_from_vm(&set_value, set, sizeof(sigset_t));
switch (how) {
case SIG_BLOCK:
m_signal_mask |= set_value;
break;
case SIG_SETMASK:
m_signal_mask = set_value;
break;
case SIG_UNBLOCK:
m_signal_mask &= ~set_value;
break;
default:
return -EINVAL;
}
}
return 0;
}
int Emulator::virt$sigreturn()
{
u32 stack_ptr = m_cpu.esp().value();