proc_self

Crates.ioproc_self
lib.rsproc_self
version0.2.0
sourcesrc
created_at2018-07-26 14:01:45.069573
updated_at2019-01-11 13:06:56.892785
descriptionCross-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`). Integrated into https://github.com/alecmocatta/palaver
homepagehttps://github.com/alecmocatta/palaver
repositoryhttps://github.com/alecmocatta/palaver
max_upload_size
id76043
size14,507
Alec Mocatta (alecmocatta)

documentation

https://docs.rs/palaver/0.1.1

README

proc_self

Docs


Note: This crate has been integrated into https://github.com/alecmocatta/palaver. Use that instead.


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());

License

Licensed under Apache License, Version 2.0, (LICENSE.txt or http://www.apache.org/licenses/LICENSE-2.0).

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Commit count: 159

cargo fmt