Crate proc_self[−][src]
Cross-platform /proc/self functionality.
This library enables limited /proc/self functionality, including getting the current executable, open file descriptors, and paths for open file descriptors that can be passed to e.g. exec (for those systems without fexecve).
It's currently used on unix-family systems; most Windows functionality is TODO.
Examples
extern crate nix; extern crate proc_self; use std::io::Read; use proc_self::*; // Close all file descriptors except std{in,out,err}. for fd in FdIter::new().unwrap() { if fd > 2 { nix::unistd::close(fd).unwrap(); } } let mut current_binary = vec![]; exe().unwrap().read_to_end(&mut current_binary).unwrap(); println!("Current binary is {} bytes long!", current_binary.len());
Structs
| FdIter |
Iterator for all open file descriptors. Doesn't work on Windows. |
Functions
| exe |
Returns a File of the currently running executable. Akin to |
| exe_path |
Returns the path of the currently running executable. On Linux this is |
| fd_dir |
Returns the path of the directory that contains entries for each open file descriptor. On Linux this is |
| fd_path |
Returns the path of the entry for a particular open file descriptor. On Linux this is |