Fix erroneous times() call in udpstat/tcpstat.
Reported by John Peace, bug #312. Also fix times(2) man page.
This commit is contained in:
parent
6539c356c6
commit
a8ebc69c6e
3 changed files with 11 additions and 4 deletions
|
@ -52,6 +52,7 @@ int main(int argc, char*argv[])
|
|||
clock_t now;
|
||||
int fl;
|
||||
int a_flag, n_flag, v_flag;
|
||||
struct tms tmsbuf;
|
||||
|
||||
getsysinfo_up(PM_PROC_NR, SIU_SYSTEMHZ, sizeof(system_hz), &system_hz);
|
||||
|
||||
|
@ -130,7 +131,7 @@ int main(int argc, char*argv[])
|
|||
}
|
||||
now= uptime.tv_sec * HZ + (uptime.tv_usec*HZ/1000000);
|
||||
#else /* Minix 3 */
|
||||
now= times(NULL);
|
||||
now= times(&tmsbuf);
|
||||
#endif
|
||||
|
||||
for (i= 0; i<TCP_CONN_NR; i++)
|
||||
|
|
|
@ -56,6 +56,7 @@ int main(int argc, char*argv[])
|
|||
clock_t now;
|
||||
int fl;
|
||||
int a_flag, n_flag;
|
||||
struct tms tmsbuf;
|
||||
|
||||
(prog_name=strrchr(argv[0], '/')) ? prog_name++ : (prog_name=argv[0]);
|
||||
|
||||
|
@ -221,7 +222,7 @@ int main(int argc, char*argv[])
|
|||
}
|
||||
now= uptime.tv_sec * HZ + (uptime.tv_usec*HZ/1000000);
|
||||
#else /* Minix 3 */
|
||||
now= times(NULL);
|
||||
now= times(&tmsbuf);
|
||||
#endif
|
||||
|
||||
for (i= 0; i<UDP_FD_NR; i++)
|
||||
|
|
|
@ -23,7 +23,7 @@ returns time-accounting information
|
|||
for the current process
|
||||
and for the terminated child processes
|
||||
of the current process.
|
||||
All times are in 1/CLOCKS_PER_SEC seconds.
|
||||
All times are in system clock ticks.
|
||||
.PP
|
||||
This is the structure returned by
|
||||
.BR times :
|
||||
|
@ -51,9 +51,14 @@ of the children's process times and
|
|||
their children's times.
|
||||
.SH RETURN
|
||||
.B Times
|
||||
returns 0 on success, otherwise \-1 with the error code stored into the
|
||||
returns the number of system clock ticks since boot time on success,
|
||||
otherwise \-1 with the error code stored into the
|
||||
global variable
|
||||
.BR errno .
|
||||
Since \-1 is also a valid return value upon success, one should clear
|
||||
.B errno
|
||||
before calling this function, and if \-1 is returned,
|
||||
check its value again afterwards.
|
||||
.SH ERRORS
|
||||
The following error code may be set in
|
||||
.BR errno :
|
||||
|
|
Loading…
Reference in a new issue