Skip to content

Commit

Permalink
Merge pull request #831 from thecoder-001/main
Browse files Browse the repository at this point in the history
macOS: fix crash if there exists a uid not associated with any user
  • Loading branch information
aristocratos authored Apr 28, 2024
2 parents b991e68 + 5ba45f7 commit 0e07deb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/osx/btop_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,11 @@ namespace Proc {
new_proc.ppid = kproc.kp_eproc.e_ppid;
new_proc.cpu_s = kproc.kp_proc.p_starttime.tv_sec * 1'000'000 + kproc.kp_proc.p_starttime.tv_usec;
struct passwd *pwd = getpwuid(kproc.kp_eproc.e_ucred.cr_uid);
new_proc.user = pwd->pw_name;
if (pwd != nullptr) {
new_proc.user = pwd->pw_name;
} else {
new_proc.user = std::to_string(kproc.kp_eproc.e_ucred.cr_uid);
}
}
new_proc.p_nice = kproc.kp_proc.p_nice;
new_proc.state = kproc.kp_proc.p_stat;
Expand Down

0 comments on commit 0e07deb

Please sign in to comment.