Skip to content

Commit 98f90f2

Browse files
xtqqczzesylvestre
authored andcommitted
feat(uucore): support signals feature on Haiku targets
Add Haiku to the platforms supporting the `signals` feature and define its signal set from `posix/signal.h`. The feature now compiles successfully on Haiku targets: ```sh RUSTC_BOOTSTRAP=1 cargo clippy --quiet -Zbuild-std --package=uucore --features=signals --all-targets --target=i686-unknown-haiku --target=x86_64-unknown-haiku ```
1 parent 85cdb67 commit 98f90f2

4 files changed

Lines changed: 80 additions & 2 deletions

File tree

‎src/uucore/src/lib/features.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub mod selinux;
116116
target_os = "android",
117117
target_os = "cygwin",
118118
target_os = "freebsd",
119+
target_os = "haiku",
119120
target_os = "hurd",
120121
target_os = "illumos",
121122
target_os = "linux",

‎src/uucore/src/lib/features/signals.rs‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,82 @@ pub static ALL_SIGNALS: [&str; 32] = [
9292
"XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "INFO", "USR1", "USR2",
9393
];
9494

95+
/*
96+
97+
The following signals are defined in Haiku:
98+
// https://github.com/haiku/haiku/blob/master/headers/posix/signal.h
99+
100+
SIGHUP 1 hangup -- tty is gone!
101+
SIGINT 2 interrupt
102+
SIGQUIT 3 `quit' special character typed in tty
103+
SIGILL 4 illegal instruction
104+
SIGCHLD 5 child process exited
105+
SIGABRT 6 abort() called, dont' catch
106+
SIGPIPE 7 write to a pipe w/no readers
107+
SIGFPE 8 floating point exception
108+
SIGKILL 9 kill a team (not catchable)
109+
SIGSTOP 10 suspend a thread (not catchable)
110+
SIGSEGV 11 segmentation violation (read: invalid pointer)
111+
SIGCONT 12 continue execution if suspended
112+
SIGTSTP 13 `stop' special character typed in tty
113+
SIGALRM 14 an alarm has gone off (see alarm())
114+
SIGTERM 15 termination requested
115+
SIGTTIN 16 read of tty from bg process
116+
SIGTTOU 17 write to tty from bg process
117+
SIGUSR1 18 app defined signal 1
118+
SIGUSR2 19 app defined signal 2
119+
SIGWINCH 20 tty window size changed
120+
SIGKILLTHR 21 be specific: kill just the thread, not team
121+
SIGTRAP 22 Trace/breakpoint trap
122+
SIGPOLL 23 Pollable event
123+
SIGPROF 24 Profiling timer expired
124+
SIGSYS 25 Bad system call
125+
SIGURG 26 High bandwidth data is available at socket
126+
SIGVTALRM 27 Virtual timer expired
127+
SIGXCPU 28 CPU time limit exceeded
128+
SIGXFSZ 29 File size limit exceeded
129+
SIGBUS 30 access to undefined portion of a memory object
130+
SIGRESERVED1 31 reserved for future use
131+
SIGRESERVED2 32 reserved for future use
132+
*/
133+
134+
#[cfg(target_os = "haiku")]
135+
pub static ALL_SIGNALS: [&str; 33] = [
136+
"EXIT",
137+
"HUP",
138+
"INT",
139+
"QUIT",
140+
"ILL",
141+
"CHLD",
142+
"ABRT",
143+
"PIPE",
144+
"FPE",
145+
"KILL",
146+
"STOP",
147+
"SEGV",
148+
"CONT",
149+
"TSTP",
150+
"ALRM",
151+
"TERM",
152+
"TTIN",
153+
"TTOU",
154+
"USR1",
155+
"USR2",
156+
"WINCH",
157+
"KILLTHR",
158+
"TRAP",
159+
"POLL",
160+
"PROF",
161+
"SYS",
162+
"URG",
163+
"VTALRM",
164+
"XCPU",
165+
"XFSZ",
166+
"BUS",
167+
"RESERVED1",
168+
"RESERVED2",
169+
];
170+
95171
/*
96172
97173
The following signals are defined in GNU/Hurd:

‎src/uucore/src/lib/lib.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pub use crate::features::safe_traversal;
116116
target_os = "android",
117117
target_os = "cygwin",
118118
target_os = "freebsd",
119+
target_os = "haiku",
119120
target_os = "hurd",
120121
target_os = "illumos",
121122
target_os = "linux",

‎src/uucore_procs/src/lib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub fn main(args: TokenStream, stream: TokenStream) -> TokenStream {
3333
// Initialize SIGPIPE state capture at process startup (Unix only).
3434
// This must be at module level to set up the .init_array static that runs
3535
// before main() to capture whether SIGPIPE was ignored by the parent process.
36-
#[cfg(all(#signals, unix, not(any(target_os = "fuchsia", target_os = "haiku"))))]
36+
#[cfg(all(#signals, unix, not(target_os = "fuchsia")))]
3737
uucore::init_startup_state_capture!();
3838

3939
pub fn uumain(args: impl uucore::Args) -> i32 {
@@ -43,7 +43,7 @@ pub fn main(args: TokenStream, stream: TokenStream) -> TokenStream {
4343
// The Rust runtime ignores SIGPIPE, but we need to respect the parent's
4444
// signal disposition for proper pipeline behavior (GNU compatibility).
4545
// needed even for true --version
46-
#[cfg(all(unix, not(any(target_os = "fuchsia", target_os = "haiku"))))]
46+
#[cfg(all(unix, not(target_os = "fuchsia")))]
4747
if !uucore::signals::sigpipe_was_ignored() {
4848
let _ = uucore::signals::enable_pipe_errors();
4949
}

0 commit comments

Comments
 (0)