refactor: optimize imports
parent
25e63c2aae
commit
ea076dcf72
@ -0,0 +1,13 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum Error {
|
||||
#[error("Renice error: {0}")]
|
||||
ReniceError(std::io::Error),
|
||||
|
||||
#[error("FFmpeg error: {0}")]
|
||||
FFmpegError(std::io::Error),
|
||||
|
||||
#[error("Job error: {0}")]
|
||||
JobError(std::io::Error),
|
||||
}
|
@ -1,10 +1,19 @@
|
||||
use std::error::Error;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn renice(pid: u32, niceness: u8) -> Result<(), Box<dyn Error>> {
|
||||
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());
|
||||
command.spawn()?;
|
||||
Ok(())
|
||||
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))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue