/// Gets the current environment for the process.  This is done by reading the
/// `/proc/pid/environ` file.
Gets the current environment for the process.  This is done by reading the
`/proc/pid/environ` file.
Gets the current environment for the process . This is done by reading the ` / proc / pid / environ ` file .
pub fn environ(&self) -> ProcResult<HashMap<OsString, OsString>> {
        use std::ffi::OsStr;
        use std::fs::File;
        use std::os::unix::ffi::OsStrExt;
        let mut map = HashMap::new();
        let mut file = proctry!(File::open(self.root.join("environ")));
        let mut buf = Vec::new();
        proctry!(file.read_to_end(&mut buf));
        for slice in buf.split(|b| *b == 0) {
            // slice will be in the form key=var, so split on the first equals sign
            let mut split = slice.splitn(2, |b| *b == b'=');
            if let (Some(k), Some(v)) = (split.next(), split.next()) {
                map.insert(
                    OsStr::from_bytes(k).to_os_string(),
                    OsStr::from_bytes(v).to_os_string(),
                );
            };
            //let env = OsStr::from_bytes(slice);
        }
        ProcResult::Ok(map)
    }
pub fn environ ( & self ) -> ProcResult < HashMap < OsString , OsString > > { use std :: ffi :: OsStr ; use std :: fs :: File ; use std :: os :: unix :: ffi :: OsStrExt ; let mut map = HashMap :: new ( ) ; let mut file = proctry ! ( File open ( self root join ( " " ) ) ) ; let mut buf = Vec :: new ( ) ; proctry ! ( file read_to_end ( mut buf ) ) ; for slice in buf . split ( | b | * b == 0 ) { // slice will be in the form key=var, so split on the first equals sign let mut split = slice . splitn ( 2 , | b | * b == b'=' ) ; if let ( Some ( k ) , Some ( v ) ) = ( split . next ( ) , split . next ( ) ) { map . insert ( OsStr :: from_bytes ( k ) . to_os_string ( ) , OsStr :: from_bytes ( v ) . to_os_string ( ) , ) ; } ; //let env = OsStr::from_bytes(slice); } ProcResult :: Ok ( map ) }
Gets the current environment for the process.
Gets the current environment for the process .
&self