#process #ptrace #enabled #spawn #command #exec #command-ptrace-spawn

bin+lib spawn-ptrace

Spawn a process with ptrace enabled

3 releases

0.1.2 Oct 16, 2020
0.1.1 Jan 3, 2018
0.1.0 May 19, 2017

#11 in #ptrace

Download history 40/week @ 2024-02-25 5/week @ 2024-03-03 5/week @ 2024-03-10 3/week @ 2024-03-17

53 downloads per month
Used in 2 crates

MIT license

7KB
64 lines

Build Status crates.io

This crate allows you to spawn a child process with ptrace enabled. It provides a single trait—CommandPtraceSpawn—that is implemented for std::process::Command, giving you access to a spawn_ptrace method.

Processes spawned this way will be stopped with SIGTRAP from their exec, so you can perform any early intervention you require prior to the process running any code and then use PTRACE_CONT to resume its execution.

Example

use std::io;
use spawn_ptrace::CommandPtraceSpawn;
use std::process::Command;

fn main() -> io::Result<()> {
   let child = Command::new("/bin/ls").spawn_ptrace()?;
   // call `ptrace(PTRACE_CONT, child.id(), ...)` to continue execution
   // do other ptrace things here...
   Ok(())
}

For a practical example of this crate's usage, see my tracetree tool.

License

This software is provided under the MIT license. See LICENSE.

Dependencies

~1.5MB
~35K SLoC