mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-08-03 06:27:45 +00:00
Replace missing signal() by libc kill() directly
This commit is contained in:
parent
66a40d555d
commit
28302555b8
1 changed files with 8 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
#![crate_name = "timeout"]
|
#![crate_name = "timeout"]
|
||||||
|
#![feature(process_id)]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the uutils coreutils package.
|
* This file is part of the uutils coreutils package.
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
use libc::pid_t;
|
||||||
use std::io::{ErrorKind, Write};
|
use std::io::{ErrorKind, Write};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::os::unix::process::ExitStatusExt;
|
use std::os::unix::process::ExitStatusExt;
|
||||||
|
@ -125,7 +127,9 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af
|
||||||
match process.wait() {
|
match process.wait() {
|
||||||
Ok(status) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
Ok(status) => status.code().unwrap_or_else(|| status.signal().unwrap()),
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.signal(signal as isize));
|
if unsafe { libc::funcs::posix88::signal::kill(process.id() as pid_t, signal as i32) } != 0 {
|
||||||
|
return ERR_EXIT_STATUS;
|
||||||
|
}
|
||||||
process.set_timeout(Some((kill_after * 1000f64) as u64));
|
process.set_timeout(Some((kill_after * 1000f64) as u64));
|
||||||
match process.wait() {
|
match process.wait() {
|
||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
|
@ -140,7 +144,9 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af
|
||||||
// XXX: this may not be right
|
// XXX: this may not be right
|
||||||
return 124;
|
return 124;
|
||||||
}
|
}
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.signal(signals::signal_by_name_or_value("KILL").unwrap() as isize));
|
if unsafe { libc::funcs::posix88::signal::kill(process.id() as pid_t, signals::signal_by_name_or_value("KILL").unwrap() as i32) } != 0 {
|
||||||
|
return ERR_EXIT_STATUS;
|
||||||
|
}
|
||||||
process.set_timeout(None);
|
process.set_timeout(None);
|
||||||
return_if_err!(ERR_EXIT_STATUS, process.wait());
|
return_if_err!(ERR_EXIT_STATUS, process.wait());
|
||||||
137
|
137
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue