From 9ceb7ef5574baa490631fa205448208cdf5b5f87 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Tue, 8 Sep 2026 23:06:10 +0100 Subject: [PATCH] feat(uucore): support signals feature on Haiku targets ```sh RUSTC_BOOTSTRAP=1 cargo clippy -q -Zbuild-std \ -p uucore --features signals --all-targets \ --target x86_64-unknown-haiku ``` --- src/uucore/src/lib/features.rs | 1 + src/uucore/src/lib/features/signals.rs | 76 ++++++++++++++++++++++++++ src/uucore/src/lib/lib.rs | 1 + src/uucore_procs/src/lib.rs | 4 +- 4 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/uucore/src/lib/features.rs b/src/uucore/src/lib/features.rs index 16d6c74b15e..facb0895490 100644 --- a/src/uucore/src/lib/features.rs +++ b/src/uucore/src/lib/features.rs @@ -120,6 +120,7 @@ pub mod selinux; target_os = "android", target_os = "cygwin", target_os = "freebsd", + target_os = "haiku", target_os = "hurd", target_os = "illumos", target_os = "linux", diff --git a/src/uucore/src/lib/features/signals.rs b/src/uucore/src/lib/features/signals.rs index 47b6d7e7de9..a517c47ccc9 100644 --- a/src/uucore/src/lib/features/signals.rs +++ b/src/uucore/src/lib/features/signals.rs @@ -92,6 +92,82 @@ pub static ALL_SIGNALS: [&str; 32] = [ "XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "INFO", "USR1", "USR2", ]; +/* + + The following signals are defined in Haiku: + // https://github.com/haiku/haiku/blob/master/headers/posix/signal.h + + SIGHUP 1 hangup -- tty is gone! + SIGINT 2 interrupt + SIGQUIT 3 `quit' special character typed in tty + SIGILL 4 illegal instruction + SIGCHLD 5 child process exited + SIGABRT 6 abort() called, dont' catch + SIGPIPE 7 write to a pipe w/no readers + SIGFPE 8 floating point exception + SIGKILL 9 kill a team (not catchable) + SIGSTOP 10 suspend a thread (not catchable) + SIGSEGV 11 segmentation violation (read: invalid pointer) + SIGCONT 12 continue execution if suspended + SIGTSTP 13 `stop' special character typed in tty + SIGALRM 14 an alarm has gone off (see alarm()) + SIGTERM 15 termination requested + SIGTTIN 16 read of tty from bg process + SIGTTOU 17 write to tty from bg process + SIGUSR1 18 app defined signal 1 + SIGUSR2 19 app defined signal 2 + SIGWINCH 20 tty window size changed + SIGKILLTHR 21 be specific: kill just the thread, not team + SIGTRAP 22 Trace/breakpoint trap + SIGPOLL 23 Pollable event + SIGPROF 24 Profiling timer expired + SIGSYS 25 Bad system call + SIGURG 26 High bandwidth data is available at socket + SIGVTALRM 27 Virtual timer expired + SIGXCPU 28 CPU time limit exceeded + SIGXFSZ 29 File size limit exceeded + SIGBUS 30 access to undefined portion of a memory object + SIGRESERVED1 31 reserved for future use + SIGRESERVED2 32 reserved for future use +*/ + +#[cfg(target_os = "haiku")] +pub static ALL_SIGNALS: [&str; 33] = [ + "EXIT", + "HUP", + "INT", + "QUIT", + "ILL", + "CHLD", + "ABRT", + "PIPE", + "FPE", + "KILL", + "STOP", + "SEGV", + "CONT", + "TSTP", + "ALRM", + "TERM", + "TTIN", + "TTOU", + "USR1", + "USR2", + "WINCH", + "KILLTHR", + "TRAP", + "POLL", + "PROF", + "SYS", + "URG", + "VTALRM", + "XCPU", + "XFSZ", + "BUS", + "RESERVED1", + "RESERVED2", +]; + /* The following signals are defined in GNU/Hurd: diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 171afe80d1a..033b1c5573a 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -120,6 +120,7 @@ pub use crate::features::safe_traversal; target_os = "android", target_os = "cygwin", target_os = "freebsd", + target_os = "haiku", target_os = "hurd", target_os = "illumos", target_os = "linux", diff --git a/src/uucore_procs/src/lib.rs b/src/uucore_procs/src/lib.rs index afb2dd54622..e74bbd3c888 100644 --- a/src/uucore_procs/src/lib.rs +++ b/src/uucore_procs/src/lib.rs @@ -33,7 +33,7 @@ pub fn main(args: TokenStream, stream: TokenStream) -> TokenStream { // Initialize SIGPIPE state capture at process startup (Unix only). // This must be at module level to set up the .init_array static that runs // before main() to capture whether SIGPIPE was ignored by the parent process. - #[cfg(all(#signals, unix, not(any(target_os = "fuchsia", target_os = "haiku"))))] + #[cfg(all(#signals, unix, not(target_os = "fuchsia")))] uucore::init_startup_state_capture!(); pub fn uumain(args: impl uucore::Args) -> i32 { @@ -43,7 +43,7 @@ pub fn main(args: TokenStream, stream: TokenStream) -> TokenStream { // The Rust runtime ignores SIGPIPE, but we need to respect the parent's // signal disposition for proper pipeline behavior (GNU compatibility). // needed even for true --version - #[cfg(all(unix, not(any(target_os = "fuchsia", target_os = "haiku"))))] + #[cfg(all(unix, not(target_os = "fuchsia")))] if !uucore::signals::sigpipe_was_ignored() { let _ = uucore::signals::enable_pipe_errors(); }