fn terminal_name() -> String {
            let mut terminal_pid = get_parent(unsafe { libc::getppid() });

            let path = PathBuf::from("/proc")
                .join(terminal_pid.to_string())
                .join("status");

            // The below loop will traverse /proc to find the
            // terminal inside of which the user is operating
            if let Ok(mut terminal_name) = fs::read_to_string(path) {
                terminal_name = terminal_name.split_whitespace().next().unwrap().to_owned();

                // Any command_name we find that matches
                // one of the elements in common_shells()
                // is effectively ignored
                while extra::common_shells().contains(&terminal_name.as_str()) {
                    let ppid = get_parent(terminal_pid);
                    terminal_pid = ppid;

                    let path = PathBuf::from("/proc")
                        .join(terminal_pid.to_string())
                        .join("status");

                    if let Ok(status) = fs::read_to_string(path) {
                        if let Some(name) = status.split_whitespace().next() {
                            terminal_name = name.to_string();
                        }
                    }
                }

                return terminal_name;
            }

            String::new()
        }
// This function returns the name associated with a given PPID
This function returns the name associated with a given PPID
This function returns the name associated with a given PPID
fn terminal_name() -> String {
            let mut terminal_pid = get_parent(unsafe { libc::getppid() });
            let path = PathBuf::from("/proc")
                .join(terminal_pid.to_string())
                .join("status");
            // The below loop will traverse /proc to find the
            // terminal inside of which the user is operating
            if let Ok(mut terminal_name) = fs::read_to_string(path) {
                terminal_name = terminal_name.split_whitespace().next().unwrap().to_owned();
                // Any command_name we find that matches
                // one of the elements in common_shells()
                // is effectively ignored
                while extra::common_shells().contains(&terminal_name.as_str()) {
                    let ppid = get_parent(terminal_pid);
                    terminal_pid = ppid;
                    let path = PathBuf::from("/proc")
                        .join(terminal_pid.to_string())
                        .join("status");
                    if let Ok(status) = fs::read_to_string(path) {
                        if let Some(name) = status.split_whitespace().next() {
                            terminal_name = name.to_string();
                        }
                    }
                }
                return terminal_name;
            }
            String::new()
        }
fn terminal_name ( ) -> String { let mut terminal_pid = get_parent ( unsafe { libc :: getppid ( ) } ) ; let path = PathBuf :: from ( " " ) . join ( terminal_pid . to_string ( ) ) . join ( " " ) ; // The below loop will traverse /proc to find the // terminal inside of which the user is operating if let Ok ( mut terminal_name ) = fs :: read_to_string ( path ) { terminal_name = terminal_name . split_whitespace ( ) . next ( ) . unwrap ( ) . to_owned ( ) ; // Any command_name we find that matches // one of the elements in common_shells() // is effectively ignored while extra :: common_shells ( ) . contains ( & terminal_name . as_str ( ) ) { let ppid = get_parent ( terminal_pid ) ; terminal_pid = ppid ; let path = PathBuf :: from ( " " ) . join ( terminal_pid . to_string ( ) ) . join ( " " ) ; if let Ok ( status ) = fs :: read_to_string ( path ) { if let Some ( name ) = status . split_whitespace ( ) . next ( ) { terminal_name = name . to_string ( ) ; } } } return terminal_name ; } String :: new ( ) }
This function returns the name associated with a given PPID
This function returns the name associated with a given PPID