From 28302555b8cc980b4c263d7e471851fddf94e75a Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Tue, 30 Jun 2015 15:33:17 -0400 Subject: [PATCH] Replace missing signal() by libc kill() directly --- src/timeout/timeout.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/timeout/timeout.rs b/src/timeout/timeout.rs index ea65bf8c2..e1dc2798c 100644 --- a/src/timeout/timeout.rs +++ b/src/timeout/timeout.rs @@ -1,4 +1,5 @@ #![crate_name = "timeout"] +#![feature(process_id)] /* * This file is part of the uutils coreutils package. @@ -12,6 +13,7 @@ extern crate getopts; extern crate libc; +use libc::pid_t; use std::io::{ErrorKind, Write}; use std::process::{Command, Stdio}; 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() { Ok(status) => status.code().unwrap_or_else(|| status.signal().unwrap()), 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)); match process.wait() { Ok(status) => { @@ -140,7 +144,9 @@ fn timeout(cmdname: &str, args: &[String], duration: f64, signal: usize, kill_af // XXX: this may not be right 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); return_if_err!(ERR_EXIT_STATUS, process.wait()); 137