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

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

            // 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) {
                // Any command_name we find that matches
                // one of the elements within this table
                // is effectively ignored
                while extra::common_shells().contains(&terminal_name.replace('\n', "").as_str()) {
                    let ppid = get_parent(terminal_pid);
                    terminal_pid = ppid;

                    let path = PathBuf::from("/proc").join(ppid.to_string()).join("comm");

                    if let Ok(comm) = fs::read_to_string(path) {
                        terminal_name = comm;
                    }
                }

                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("comm");
            // 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) {
                // Any command_name we find that matches
                // one of the elements within this table
                // is effectively ignored
                while extra::common_shells().contains(&terminal_name.replace('\n', "").as_str()) {
                    let ppid = get_parent(terminal_pid);
                    terminal_pid = ppid;
                    let path = PathBuf::from("/proc").join(ppid.to_string()).join("comm");
                    if let Ok(comm) = fs::read_to_string(path) {
                        terminal_name = comm;
                    }
                }
                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 ) { // Any command_name we find that matches // one of the elements within this table // is effectively ignored while extra :: common_shells ( ) . contains ( & terminal_name . replace ( '\n' , " " ) . as_str ( ) ) { let ppid = get_parent ( terminal_pid ) ; terminal_pid = ppid ; let path = PathBuf :: from ( " " ) . join ( ppid . to_string ( ) ) . join ( " " ) ; if let Ok ( comm ) = fs :: read_to_string ( path ) { terminal_name = comm ; } } 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