commit 7f301a0825536738f555bca0c2f7a960c35a116c
parent 9480f701210da879ccf76e774658dd594fb80378
Author: sin <sin@2f30.org>
Date: Fri, 16 Aug 2013 14:50:01 +0100
Only parse extra things when -f is supplied
Diffstat:
M | ps.c | | | 37 | +++++++++++++++++++------------------ |
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/ps.c b/ps.c
@@ -112,26 +112,27 @@ psout(struct procstat *ps)
}
}
- procuid(ps->pid, &puid);
- errno = 0;
- pw = getpwuid(puid);
- if (errno || !pw)
- eprintf("getpwuid %d:", puid);
-
- sysinfo(&info);
- start = time(NULL) - (info.uptime - (ps->starttime / 100));
- tm = localtime(&start);
- strftime(stimestr, sizeof(stimestr),
- "%H:%M", tm);
- if (parsecmdline(ps->pid, cmdline, sizeof(cmdline)) < 0)
- cmd = ps->comm;
- else
- cmd = cmdline;
-
- if (!(flags & PS_fflag))
+ if (!(flags & PS_fflag)) {
printf("%5d %-6s %02u:%02u:%02u %s\n", ps->pid, ttystr,
sut / 3600, (sut % 3600) / 60, sut % 60, ps->comm);
- else {
+ } else {
+ procuid(ps->pid, &puid);
+ errno = 0;
+ pw = getpwuid(puid);
+ if (errno || !pw)
+ eprintf("getpwuid %d:", puid);
+
+ sysinfo(&info);
+ start = time(NULL) - (info.uptime - (ps->starttime / 100));
+ tm = localtime(&start);
+ strftime(stimestr, sizeof(stimestr),
+ "%H:%M", tm);
+
+ if (parsecmdline(ps->pid, cmdline, sizeof(cmdline)) < 0)
+ cmd = ps->comm;
+ else
+ cmd = cmdline;
+
printf("%-8s %5d %5d ? %5s %-5s %02u:%02u:%02u %s%s%s\n",
pw->pw_name, ps->pid,
ps->ppid, stimestr, ttystr,