Merge pull request #831 from thecoder-001/main

macOS: fix crash if there exists a uid not associated with any user
This commit is contained in:
Jakob P. Liljenberg
2024-04-28 22:38:28 +02:00
committed by GitHub

View File

@@ -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;