diff --git a/apps/src/ps.c b/apps/src/ps.c index c7f9fb35..1a58c8e2 100644 --- a/apps/src/ps.c +++ b/apps/src/ps.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -17,7 +18,9 @@ pid_t get_current_max_threads() void display_process(struct pstat* pstatbuf) { - printf("%d %d %ld %ld %s %s (%ld ms)\n", pstatbuf->pt_uid, pstatbuf->pt_gid, pstatbuf->pt_pid, pstatbuf->pt_ppid, + struct passwd* pwd = getpwuid(pstatbuf->pt_uid); + if (!pwd && errno) perror("getpwuid"); + printf("%s %ld %ld %s %s (%ld ms)\n", pwd ? pwd->pw_name : "???", pstatbuf->pt_pid, pstatbuf->pt_ppid, pstatbuf->pt_name, pstatname(pstatbuf), pstatbuf->pt_time); } @@ -41,4 +44,5 @@ int main() { if (try_pstat(pid, &pst)) { display_process(&pst); } } + endpwent(); } \ No newline at end of file