bool Shell::GetActiveProcessInfo(ActiveProcessInfo& _info) const { _info.Unset(); // get the foreground process group pid_t process = tcgetpgrp(fFd); if (process < 0) return false; // get more info on the process group leader KMessage info; status_t error = get_extended_team_info(process, B_TEAM_INFO_BASIC, info); if (error != B_OK) return false; // fetch the name and the current directory from the info const char* name; int32 cwdDevice; int64 cwdDirectory; if (info.FindString("name", &name) != B_OK || info.FindInt32("cwd device", &cwdDevice) != B_OK || info.FindInt64("cwd directory", &cwdDirectory) != B_OK) { return false; } // convert the node ref into a path entry_ref cwdRef(cwdDevice, cwdDirectory, "."); BPath cwdPath; if (cwdPath.SetTo(&cwdRef) != B_OK) return false; // set the result _info.SetTo(process, name, cwdPath.Path()); return true; }