Skip to content

Commit

Permalink
fix calling internal command
Browse files Browse the repository at this point in the history
Signed-off-by: Takashi IIGUNI <[email protected]>
  • Loading branch information
guni1192 committed Feb 21, 2022
1 parent 175bd4d commit 0a59b51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion sprofiler/src/command/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,17 @@ fn start_tracing(spinlock: Arc<AtomicBool>, state: &State) -> Result<()> {
if let Some(path) = annotation::get_trace_target_path(state) {
let file = File::create(path)?;
serde_json::to_writer(file, &gen_seccomp_rule()?)?;
};
}

Ok(())
}

pub fn trace_command() -> Result<()> {
let state = process::container_state_load_from_reader(io::stdin()).expect("state load error:");

let pid = std::process::id() as i32;
println!("PID: {pid}");

process::create_pid_file(state.bundle.join("sprofiler.pid"), pid)?;

let spinlock = Arc::new(AtomicBool::new(true));
Expand Down
5 changes: 3 additions & 2 deletions sprofiler/src/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ pub fn handle_dynamic_analyzer(dynamic: DynamicSubCommand) -> Result<()> {

fn run_trace_command() -> anyhow::Result<()> {
Command::new("/proc/self/exe")
.arg("dynamic")
.arg("tracer")
.stdin(Stdio::inherit())
.stdout(Stdio::null())
.stderr(Stdio::null())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.spawn()?;

Ok(())
Expand Down

0 comments on commit 0a59b51

Please sign in to comment.