Skip to content

Commit 8e2a694

Browse files
committed
fixes segfault when can't get username via posix getpwuid
1 parent 7c38027 commit 8e2a694

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Managers/Process.vala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class Monitor.Process : GLib.Object {
1818
// User id
1919
public int uid;
2020

21-
public string username;
21+
public string username = Utils.NO_DATA;
2222

2323
Icon _icon;
2424
public Icon icon {
@@ -83,9 +83,14 @@ public class Monitor.Process : GLib.Object {
8383
GTop.get_proc_uid (out proc_uid, stat.pid);
8484
uid = proc_uid.uid;
8585

86-
// getting username
87-
unowned Posix.Passwd passwd = Posix.getpwuid (uid);
88-
username = passwd.pw_name;
86+
87+
// getting username
88+
// @TOFIX: Can't get username for postgres when started from docker (?)
89+
unowned Posix.Passwd passwd = Posix.getpwuid (uid);
90+
if (passwd != null){
91+
username = passwd.pw_name;
92+
}
93+
8994

9095
exists = parse_stat () && read_cmdline ();
9196
get_usage (0, 1);

0 commit comments

Comments
 (0)