1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 03:57:44 +00:00

Merge pull request #6806 from Ecordonnier/eco/signal-handler

uucore: disable default signal-handlers added by Rust
This commit is contained in:
Sylvestre Ledru 2024-10-30 08:36:01 +01:00 committed by GitHub
commit bf6de81a1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 142 additions and 4 deletions

View file

@ -4,9 +4,11 @@
// file that was distributed with this source code.
use rstest::rstest;
// spell-checker:ignore dont
// spell-checker:ignore dont SIGBUS SIGSEGV sigsegv sigbus
use crate::common::util::TestScenario;
#[cfg(unix)]
use nix::sys::signal::Signal::{SIGBUS, SIGSEGV};
use std::time::{Duration, Instant};
#[test]
@ -135,6 +137,40 @@ fn test_sleep_wrong_time() {
new_ucmd!().args(&["0.1s", "abc"]).fails();
}
#[test]
#[cfg(unix)]
fn test_sleep_stops_after_sigsegv() {
let mut child = new_ucmd!()
.arg("100")
.timeout(Duration::from_secs(10))
.run_no_wait();
child
.delay(100)
.kill_with_custom_signal(SIGSEGV)
.make_assertion()
.with_current_output()
.signal_is(SIGSEGV as i32) // make sure it was us who terminated the process
.no_output();
}
#[test]
#[cfg(unix)]
fn test_sleep_stops_after_sigbus() {
let mut child = new_ucmd!()
.arg("100")
.timeout(Duration::from_secs(10))
.run_no_wait();
child
.delay(100)
.kill_with_custom_signal(SIGBUS)
.make_assertion()
.with_current_output()
.signal_is(SIGBUS as i32) // make sure it was us who terminated the process
.no_output();
}
#[test]
fn test_sleep_when_single_input_exceeds_max_duration_then_no_error() {
let mut child = new_ucmd!()