Implement printing a list of SysV IPC mqs
What could be improved is when printing the information to use a better human readable format. As usual the readme and the man page are both updated.
This commit is contained in:
parent
f4796e7da6
commit
4c82d41f8e
5 changed files with 46 additions and 0 deletions
26
src/sysv/list.rs
Normal file
26
src/sysv/list.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
use anyhow::Result;
|
||||
use clap::Clap;
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufRead, BufReader},
|
||||
};
|
||||
|
||||
/// Print a list of existing message queues
|
||||
#[derive(Clap, Debug)]
|
||||
pub struct List {}
|
||||
|
||||
impl List {
|
||||
pub fn run(&self) -> Result<()> {
|
||||
let file = BufReader::new(File::open("/proc/sysvipc/msg")?);
|
||||
|
||||
for line in file.lines() {
|
||||
for field in line?.split_whitespace().collect::<Vec<&str>>() {
|
||||
print!("{0: <10}", field);
|
||||
}
|
||||
|
||||
println!();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue