Check return value of sysinfo()

This commit is contained in:
sin 2013-08-16 15:51:37 +01:00
parent f088b12877
commit 9e8a7ac616
3 changed files with 6 additions and 3 deletions

3
free.c
View File

@ -24,7 +24,8 @@ main(int argc, char *argv[])
{
struct sysinfo info;
sysinfo(&info);
if (sysinfo(&info) < 0)
eprintf("sysinfo:");
mem_unit = info.mem_unit ? info.mem_unit : 1;
ARGBEGIN {

3
ps.c
View File

@ -122,7 +122,8 @@ psout(struct procstat *ps)
if (errno || !pw)
eprintf("getpwuid %d:", puid);
sysinfo(&info);
if (sysinfo(&info) < 0)
eprintf("sysinfo:");
start = time(NULL) - info.uptime;
start += (ps->starttime / sysconf(_SC_CLK_TCK));
tm = localtime(&start);

View File

@ -29,7 +29,8 @@ main(int argc, char *argv[])
usage();
} ARGEND;
sysinfo(&info);
if (sysinfo(&info) < 0)
eprintf("sysinfo:");
time(&tmptime);
now = localtime(&tmptime);
printf(" %02d:%02d:%02d up ", now->tm_hour, now->tm_min, now->tm_sec);