[LTP] [PATCH] process_state: Enhancement of process state detection
Li Wang
liwang@redhat.com
Wed Feb 7 03:21:15 CET 2024
On Tue, Feb 6, 2024 at 7:51 PM Petr Vorel <pvorel@suse.cz> wrote:
> Hi Li, Ian,
>
> > The functions will be more robust against process names with
> > unusual characters and will correctly read the state character
> > from the /proc/[pid]/stat file. This is a necessary change
> > because the process name, which is a free-form string, can
> > contain spaces and other characters that would otherwise
> > disrupt the simple parsing logic of the original format string.
>
> > e.g.
> > $ cat /proc/792442/stat
> > 792442 (Web Content) S 164213 4351 4351 0 -1 4194560 ...
>
> > Reported-by: Ian Wienand <iwienand@redhat.com>
> > Signed-off-by: Li Wang <liwang@redhat.com>
> > Cc: Chunyu Hu <chuhu@redhat.com>
> > ---
> > lib/tst_process_state.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> > diff --git a/lib/tst_process_state.c b/lib/tst_process_state.c
> > index 08a9d0966..c15283c3d 100644
> > --- a/lib/tst_process_state.c
> > +++ b/lib/tst_process_state.c
> > @@ -22,7 +22,7 @@ int tst_process_state_wait(const char *file, const int
> lineno,
>
> > for (;;) {
> > safe_file_scanf(file, lineno, cleanup_fn, proc_path,
> > - "%*i %*s %c", &cur_state);
> > + "%*[^)]%*c %c", &cur_state);
>
> Obviously correct, thanks.
>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
>
> But there is also the same issue in lib/tst_thread_state.c,
> I guess it applies to that. Li, could you please also fix it before merge?
>
Good point, applied with the tst_thread_state change.
>
> Also, Andrea, you added tst_thread_state_wait() and
> TST_THREAD_STATE_WAIT() for
> futex_waitv0[23] related tests [1], but it's now not used anywhere due
> Jan's
> changes [2] [3]. I wonder if it's still useful or whether we should remove
> it.
>
Agreed with Jan, it is still useful in the future.
--
Regards,
Li Wang
More information about the ltp
mailing list