Check return value of sysinfo()
This commit is contained in:
parent
f088b12877
commit
9e8a7ac616
3
free.c
3
free.c
@ -24,7 +24,8 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
struct sysinfo info;
|
struct sysinfo info;
|
||||||
|
|
||||||
sysinfo(&info);
|
if (sysinfo(&info) < 0)
|
||||||
|
eprintf("sysinfo:");
|
||||||
mem_unit = info.mem_unit ? info.mem_unit : 1;
|
mem_unit = info.mem_unit ? info.mem_unit : 1;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
|
3
ps.c
3
ps.c
@ -122,7 +122,8 @@ psout(struct procstat *ps)
|
|||||||
if (errno || !pw)
|
if (errno || !pw)
|
||||||
eprintf("getpwuid %d:", puid);
|
eprintf("getpwuid %d:", puid);
|
||||||
|
|
||||||
sysinfo(&info);
|
if (sysinfo(&info) < 0)
|
||||||
|
eprintf("sysinfo:");
|
||||||
start = time(NULL) - info.uptime;
|
start = time(NULL) - info.uptime;
|
||||||
start += (ps->starttime / sysconf(_SC_CLK_TCK));
|
start += (ps->starttime / sysconf(_SC_CLK_TCK));
|
||||||
tm = localtime(&start);
|
tm = localtime(&start);
|
||||||
|
3
uptime.c
3
uptime.c
@ -29,7 +29,8 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
sysinfo(&info);
|
if (sysinfo(&info) < 0)
|
||||||
|
eprintf("sysinfo:");
|
||||||
time(&tmptime);
|
time(&tmptime);
|
||||||
now = localtime(&tmptime);
|
now = localtime(&tmptime);
|
||||||
printf(" %02d:%02d:%02d up ", now->tm_hour, now->tm_min, now->tm_sec);
|
printf(" %02d:%02d:%02d up ", now->tm_hour, now->tm_min, now->tm_sec);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user