rustfmt the code
This commit is contained in:
parent
3dcdc952d5
commit
e99a1184d0
@ -1,6 +1,6 @@
|
|||||||
use sysinfo::{System};
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
use sysinfo::System;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let system = System::new_all();
|
let system = System::new_all();
|
||||||
|
@ -1,34 +1,31 @@
|
|||||||
use std::env;
|
|
||||||
use std::process;
|
|
||||||
use std::str::FromStr;
|
|
||||||
use libc::{c_char, c_int, execvp, PRIO_PROCESS};
|
use libc::{c_char, c_int, execvp, PRIO_PROCESS};
|
||||||
|
use std::env;
|
||||||
use std::io::{Error, Write};
|
use std::io::{Error, Write};
|
||||||
|
use std::process;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
fn main() {
|
if args.len() != 3 {
|
||||||
let args: Vec<String> = env::args().collect();
|
eprintln!("Usage: renice <nice value> <pid>");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if args.len() != 3 {
|
let nice_value = i32::from_str(&args[1]).unwrap_or_else(|_| {
|
||||||
eprintln!("Usage: renice <nice value> <pid>");
|
eprintln!("Invalid nice value");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
});
|
||||||
|
|
||||||
let nice_value = i32::from_str(&args[1]).unwrap_or_else(|_| {
|
let pid = i32::from_str(&args[2]).unwrap_or_else(|_| {
|
||||||
eprintln!("Invalid nice value");
|
eprintln!("Invalid PID");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
let pid = i32::from_str(&args[2]).unwrap_or_else(|_| {
|
|
||||||
eprintln!("Invalid PID");
|
|
||||||
process::exit(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
if unsafe { libc::setpriority(PRIO_PROCESS, pid.try_into().unwrap(), nice_value) } == -1 {
|
if unsafe { libc::setpriority(PRIO_PROCESS, pid.try_into().unwrap(), nice_value) } == -1 {
|
||||||
eprintln!("Failed to set nice value: {}", Error::last_os_error());
|
eprintln!("Failed to set nice value: {}", Error::last_os_error());
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Nice value of process {} set to {}", pid, nice_value);
|
|
||||||
|
|
||||||
|
println!("Nice value of process {} set to {}", pid, nice_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user