-
Notifications
You must be signed in to change notification settings - Fork 28
/
tracer.rs
30 lines (26 loc) · 867 Bytes
/
tracer.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use anyhow::{bail, Result};
use console::Style;
use lurk_cli::{args::Args, style::StyleConfig, Tracer};
use nix::unistd::{fork, ForkResult};
use std::io;
fn main() -> Result<()> {
let command = String::from("/usr/bin/ls");
let pid = match unsafe { fork() } {
Ok(ForkResult::Child) => {
return lurk_cli::run_tracee(&[command], &[], &None);
}
Ok(ForkResult::Parent { child }) => child,
Err(err) => bail!("fork() failed: {err}"),
};
let args = Args::default();
let output = io::stdout();
let style = StyleConfig {
pid: Style::new().cyan(),
syscall: Style::new().white().bold(),
success: Style::new().green(),
error: Style::new().red(),
result: Style::new().yellow(),
use_colors: true,
};
Tracer::new(pid, args, output, style)?.run_tracer()
}