1
0
Fork 0
forked from wry/wry

compositor: reset all signals during startup

This commit is contained in:
Julian Orth 2025-04-26 19:52:05 +02:00
parent 456457eade
commit fdfc20452f
3 changed files with 16 additions and 11 deletions

View file

@ -63,6 +63,7 @@ use {
pub const MAX_EXTENTS: i32 = (1 << 22) - 1;
pub fn start_compositor(global: GlobalArgs, args: RunArgs) {
sighand::reset_all();
let forker = create_forker();
let portal = portal::run_from_compositor(global.log_level.into());
enable_profiler();

View file

@ -339,7 +339,9 @@ impl Forker {
}
set_process_name("the ol' forker");
setup_deathsig(ppid);
reset_signals();
unsafe {
c::signal(c::SIGCHLD, c::SIG_IGN);
}
let socket = Rc::new(setup_fds(socket));
std::panic::set_hook({
let socket = socket.raw();
@ -569,16 +571,6 @@ fn setup_fds(mut socket: OwnedFd) -> OwnedFd {
socket
}
fn reset_signals() {
const NSIG: c::c_int = 64;
unsafe {
for sig in 1..=NSIG {
c::signal(sig, c::SIG_DFL);
}
c::signal(c::SIGCHLD, c::SIG_IGN);
}
}
fn setup_deathsig(ppid: c::pid_t) {
unsafe {
let res = c::prctl(c::PR_SET_PDEATHSIG, c::SIGKILL as c::c_ulong);

View file

@ -50,3 +50,15 @@ async fn handle_signals(fd: Rc<OwnedFd>, ring: Rc<IoUring>) {
}
}
}
pub fn reset_all() {
const NSIG: c::c_int = 64;
unsafe {
for sig in 1..=NSIG {
c::signal(sig, c::SIG_DFL);
}
}
let mut set: c::sigset_t = uapi::pod_zeroed();
uapi::sigfillset(&mut set).unwrap();
let _ = uapi::pthread_sigmask(c::SIG_UNBLOCK, Some(&set), None);
}