Skip to content

env: support real-time signals and drop the nix dependency #13006

Open
sylvestre wants to merge 3 commits into
uutils:mainfrom
sylvestre:env-impro
Open

env: support real-time signals and drop the nix dependency #13006
sylvestre wants to merge 3 commits into
uutils:mainfrom
sylvestre:env-impro

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

should fix env/env-signal-handler.sh

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/symlink (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/env/env-signal-handler is no longer failing!
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.
Note: The gnu test tests/seq/seq-epipe is now being skipped but was previously passing.
Note: The gnu test tests/tail/tail-n0f is now being skipped but was previously passing.

Use rustix for process/signal handling (and libc directly where rustix
leaves signal disposition to libc), and add real-time signal support,
which nix's Signal enum can't represent. Shared signal_from_raw() and
set_disposition() helpers are reused by env. Drops nix's "poll" feature.
Use uucore::signals helpers (and libc::sigprocmask) so real-time signals
work like any other, and print their names in --list-signal-handling
instead of "?". env now execs via libc::execvp directly and drops nix.
Comment on lines +490 to +495
if let Some((rtmin, rtmax)) = realtime_signal_bounds() {
if (rtmin..=rtmax).contains(&(raw as usize)) {
return Some(raw);
}
}
None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A functional approach might be cleaner. And instead of casting raw as usize you can use signal as it is already usize. Something like:

Suggested change
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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants