Skip to content

Commit

Permalink
fixes segfault when can't get username via posix getpwuid
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Mar 4, 2023
1 parent 7c38027 commit 8e2a694
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Managers/Process.vala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Monitor.Process : GLib.Object {
// User id
public int uid;

public string username;
public string username = Utils.NO_DATA;

Icon _icon;
public Icon icon {
Expand Down Expand Up @@ -83,9 +83,14 @@ public class Monitor.Process : GLib.Object {
GTop.get_proc_uid (out proc_uid, stat.pid);
uid = proc_uid.uid;

// getting username
unowned Posix.Passwd passwd = Posix.getpwuid (uid);
username = passwd.pw_name;

// getting username
// @TOFIX: Can't get username for postgres when started from docker (?)
unowned Posix.Passwd passwd = Posix.getpwuid (uid);
if (passwd != null){
username = passwd.pw_name;
}


exists = parse_stat () && read_cmdline ();
get_usage (0, 1);
Expand Down

0 comments on commit 8e2a694

Please sign in to comment.