Repository navigation
Conversation
|
GNU testsuite comparison: |
| if let Some((rtmin, rtmax)) = realtime_signal_bounds() { | ||
| if (rtmin..=rtmax).contains(&(raw as usize)) { | ||
| return Some(raw); | ||
| } | ||
| } | ||
| None |
There was a problem hiding this comment.
A functional approach might be cleaner. And instead of casting raw as usize you can use signal as it is already usize. Something like:
| if let Some((rtmin, rtmax)) = realtime_signal_bounds() { | |
| if (rtmin..=rtmax).contains(&(raw as usize)) { | |
| return Some(raw); | |
| } | |
| } | |
| None | |
| realtime_signal_bounds().and_then(|(rtmin, rtmax)| { | |
| (rtmin..=rtmax).contains(&signal).then_some(raw) | |
| }) |
| /// `geteuid()` returns the effective user ID of the calling process. | ||
| pub fn geteuid() -> uid_t { | ||
| nix::unistd::geteuid().as_raw() | ||
| rustix::process::geteuid().as_raw() |
There was a problem hiding this comment.
Merging this PR will degrade performance by 8.72%1 warning, 1 note
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
|
Conflicts (from #11158) must be resolved. |
787b564 to
456585f
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
signal_from_rawonly accepts real-time signals whenrealtime_signal_bounds()returns… · Newset_signal_dispositiondiscards the actualio::Errorcoming from… · Newset_signal_dispositiondiscards the actualio::Errorcoming from… · New The restorationlibc::sigaction(...old...)ignores its return value. If restoring the previous… · New This changes the public function signature fromResult<(), Errno>tostd::io::Result<()>, which… · New
Review effort: Lite
| realtime_signal_bounds() | ||
| .and_then(|(rtmin, rtmax)| (rtmin..=rtmax).contains(&signal).then_some(raw)) |
| unsafe { libc::sigaction(sig_raw, &raw const old, std::ptr::null_mut()) }; | ||
| res.map_err(io::Error::from) |
| pub fn disable_rust_signal_handlers() -> std::io::Result<()> { | ||
| // rustix leaves signal dispositions to libc (see its `not_implemented::libc_internals`), | ||
| // so this goes straight to libc. | ||
| // SAFETY: the action is fully initialized below, and SIG_DFL is a valid disposition | ||
| // for both signals. | ||
| unsafe { | ||
| sigaction( | ||
| SIGBUS, | ||
| &SigAction::new(SigDfl, SaFlags::empty(), SigSet::all()), | ||
| ) | ||
| }?; | ||
| let mut action: libc::sigaction = std::mem::zeroed(); | ||
| action.sa_sigaction = libc::SIG_DFL; | ||
| libc::sigfillset(&raw mut action.sa_mask); | ||
| for signal in [libc::SIGSEGV, libc::SIGBUS] { | ||
| if libc::sigaction(signal, &raw const action, std::ptr::null_mut()) == -1 { | ||
| return Err(std::io::Error::last_os_error()); | ||
| } | ||
| } | ||
| } | ||
| Ok(()) | ||
| } |
|
sorry but it needs to be rebased |
nix's Signal cannot represent real-time signals, so uucore's process helpers rejected them with EINVAL (timeout --signal=RTMIN could not signal its child) and env had to special-case them around nix. Move the signal and process handling in uucore from nix to rustix and libc, so real-time signals can be validated, sent, ignored, reset and blocked, and drop env's nix dependency. Signal dispositions go through one libc sigaction helper in uucore (rustix does not wrap sigaction), which env, the signals feature and send_signal_group share. uucore no longer needs nix in its core, so nix is optional again and libc is required on unix instead. Should fix tests/env/env-signal-handler.sh (together with the timeout process-group fix).
There was a problem hiding this comment.
🔵 Needs a closer look
The refactor changes low-level signal and process handling across multiple Unix targets, requiring cross-platform ABI/runtime validation and the pending prerequisite PR #16821 before its process-group behavior can be assessed confidently.
3 open issues
2 resolved since last review
Review effort: Lite


should fix env/env-signal-handler.sh
The uucore process helpers rejected real-time signals (
timeout --signal=RTMINfailed with EINVAL). This switches the signal code in uucore from nix to libc, so libc becomes a required unix dependency of uucore and nix is optional again.Should land after #16821 (the timeout own-group signal fix that was split out of this PR).