peek_proc_reader/
current.rs1use std::fs;
4use std::path::Path;
5
6#[cfg(target_os = "linux")]
10pub fn read_syscall(pid: i32) -> Option<(u64, [u64; 6])> {
11 let path = Path::new("/proc").join(pid.to_string()).join("syscall");
12 let s = fs::read_to_string(&path).ok()?;
13 let s = s.trim_end();
14 let mut parts = s.split_whitespace();
16 let num: u64 = parts.next()?.parse().ok()?;
17 let mut args = [0u64; 6];
18 for (i, a) in parts.take(6).enumerate() {
19 let v = a
20 .strip_prefix("0x")
21 .and_then(|h| u64::from_str_radix(h, 16).ok())
22 .or_else(|| a.parse().ok())?;
23 args[i] = v;
24 }
25 Some((num, args))
26}
27
28#[cfg(not(target_os = "linux"))]
29pub fn read_syscall(_pid: i32) -> Option<(u64, [u64; 6])> {
30 None
31}