https://github.com/luser/spawn-ptrace
A Rust crate for spawning a Linux process with ptrace enabled
https://github.com/luser/spawn-ptrace
Last synced: about 1 year ago
JSON representation
A Rust crate for spawning a Linux process with ptrace enabled
- Host: GitHub
- URL: https://github.com/luser/spawn-ptrace
- Owner: luser
- License: mit
- Created: 2016-10-13T16:31:59.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-11-13T14:53:14.000Z (over 5 years ago)
- Last Synced: 2025-03-08T00:03:40.793Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 13.7 KB
- Stars: 8
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/luser/spawn-ptrace) [](https://crates.io/crates/spawn-ptrace) [](https://docs.rs/spawn-ptrace)
This crate allows you to spawn a child process with [`ptrace`](https://man7.org/linux/man-pages/man2/ptrace.2.html) 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
```rust,no_run
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`](https://github.com/luser/tracetree) tool.
# License
This software is provided under the MIT license. See [LICENSE](LICENSE).