were still displayed.
On 07/06/2011 08:40 AM, Kei Ishida wrote:
> Hello
>
> I found the folloring bug of pidstat. I hope this would help.
>
> [Bug description]
> Pidstat displayed pid(s) of dead process(es) every other times
> when multiple pids are specified.
>
> [How reproducible]
> Always. Run pidstat with more then pids to watch, and kill one of them.
>
> [Proposed patch]
> diff -urNp sysstat-10.0.1/pidstat.c sysstat-10.0.1_/pidstat.c
> --- sysstat-10.0.1/pidstat.c 2011-06-01 22:05:12.
000000000 +0900
> +++ sysstat-10.0.1_/pidstat.c 2011-07-06 11:05:46.
149880175 +0900
> @@ -1011,6 +1011,20 @@ int get_pid_to_display(int prev, int cur
>
> else if (DISPLAY_PID(pidflag)) {
>
> + unsigned int i;
> + int pid_exists = FALSE;
> +
> + /* See if pid exists in pid_array[] */
> + for (i = 0; i < pid_array_nr; i++) {
> + if ((*pstc)->pid == pid_array[i]) {
> + pid_exists = TRUE;
> + break;
> + }
> + }
> +
> + if (!pid_exists)
> + return 0;
> +
> *pstp = st_pid_list[prev] + p;
> }
>
>
> Regards,
> Kei Ishida
timestamps in seconds since the epoch (when applicable).
* Option "-P ON" added to mpstat. This option tells mpstat
to display stats only for online CPU.
+ * [Kei Ishida]: pidstat displayed stats for processes that
+ had terminated while pidstat was running. This is now fixed.
* [Jeroen Roovers]: Automate translation files handling in
Makefile.in.
* DTD and XSD documents updated.
David Gesswein <djg@drs[...].com>
Ladislav Hagara <ladislav.hagara@uno[...].cz>
Don Harrop <don@swb[...].com>
+ Kei Ishida <ishida.kei@oss[...].jp>
Tatsuo Ito <tito@mir[...].com>
David S. Jackson <dsj@syl[...].net>
Erik Jacobson <erikj@sub[...].com>
else if (DISPLAY_PID(pidflag)) {
*pstp = st_pid_list[prev] + p;
+
+ if (!(*pstp)->pid)
+ /* PID no longer exists */
+ return 0;
}
if (COMMAND_STRING(pidflag)) {