mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-18 20:53:40 +08:00
Signals: Compute signal set once on startup
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
Some checks failed
make test / ubuntu (push) Has been cancelled
make test / ubuntu-32bit-static-pcre2 (push) Has been cancelled
make test / ubuntu-asan (push) Has been cancelled
make test / macos (push) Has been cancelled
Rust checks / rustfmt (push) Has been cancelled
Rust checks / clippy (push) Has been cancelled
Really the only thing we're looking for here is if we're started with HUP ignored or not. Saves a syscall per external process. Continuation of #10869
This commit is contained in:
parent
3012020af3
commit
e24823dd6c
|
@ -3,7 +3,7 @@
|
|||
use super::blocked_signals_for_job;
|
||||
use crate::proc::Job;
|
||||
use crate::redirection::Dup2List;
|
||||
use crate::signal::get_signals_to_default;
|
||||
use crate::signal::signals_to_default;
|
||||
use crate::{exec::is_thompson_shell_script, libc::_PATH_BSHELL};
|
||||
use errno::Errno;
|
||||
use libc::{c_char, posix_spawn_file_actions_t, posix_spawnattr_t};
|
||||
|
@ -126,8 +126,7 @@ impl PosixSpawner {
|
|||
}
|
||||
|
||||
// Everybody gets default handlers.
|
||||
let sigdefault = get_signals_to_default();
|
||||
attr.set_sigdefault(&sigdefault)?;
|
||||
attr.set_sigdefault(&signals_to_default)?;
|
||||
|
||||
// Reset the sigmask.
|
||||
let mut sigmask = unsafe { std::mem::zeroed() };
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::topic_monitor::{topic_monitor_principal, Generation, GenerationsList,
|
|||
use crate::wchar::prelude::*;
|
||||
use crate::wutil::{fish_wcstoi, perror};
|
||||
use errno::{errno, set_errno};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::sync::atomic::{AtomicI32, Ordering};
|
||||
|
||||
/// Store the "main" pid. This allows us to reliably determine if we are in a forked child.
|
||||
|
@ -275,7 +276,7 @@ pub fn signal_handle(sig: Signal) {
|
|||
sigaction(sig, &act, std::ptr::null_mut());
|
||||
}
|
||||
|
||||
pub fn get_signals_to_default() -> libc::sigset_t {
|
||||
pub static signals_to_default: Lazy<libc::sigset_t> = Lazy::new(|| {
|
||||
let mut set: libc::sigset_t = unsafe { std::mem::zeroed() };
|
||||
unsafe { libc::sigemptyset(&mut set) };
|
||||
for data in SIGNAL_TABLE.iter() {
|
||||
|
@ -292,7 +293,7 @@ pub fn get_signals_to_default() -> libc::sigset_t {
|
|||
unsafe { libc::sigaddset(&mut set, data.signal.code()) };
|
||||
}
|
||||
return set;
|
||||
}
|
||||
});
|
||||
|
||||
/// Ensure we did not inherit any blocked signals. See issue #3964.
|
||||
pub fn signal_unblock_all() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user