19 lines
568 B
Rust
19 lines
568 B
Rust
use std::process::Command;
|
|
|
|
use crate::error;
|
|
|
|
pub fn renice(pid: u32, niceness: u8) -> Result<(), error::Error> {
|
|
let mut command = Command::new("renice");
|
|
command.arg(niceness.to_string());
|
|
command.arg(pid.to_string());
|
|
match command.output() {
|
|
Ok(output) => {
|
|
if output.status.success() {
|
|
Ok(())
|
|
} else {
|
|
Err(error::Error::ReniceError(std::io::Error::new(std::io::ErrorKind::Other, "renice failed")))
|
|
}
|
|
},
|
|
Err(e) => Err(error::Error::ReniceError(e))
|
|
}
|
|
} |