Re: [LTP] [PATCH v3 2/2] Refactor exit_group01 using new API

Cyril Hrubis
2023-11-01T12:50:16Z

Hi!
> This could fail due to PID reuse or maybe because state == 'Z'.
>
> Perhaps instead we could check the threads are put into the Z state?
>
> I guess that the child threads are reparented to init and it reaps
> them. So you will have to prevent that by setting PR_SET_CHILD_SUBREAPER
> on the main test process with prctl.
>
> The man pages are not clear on this though. I guess this is how it works
> from reading the kernel code.

What about we:

1) allocate a piece of shared memory
2) each thread would run a loop that would increment a counter in that
memory
3) the test process will wait() the main child
4) then monitor the shared memory to make sure that counters are not
incremented anymore

Also child threads shouldn't be reparented to init, as long as at least
one of the threads runs the child process is technically alive and I
guess that wait() will not return until last thread in the group is
dead.

--
Cyril Hrubis
chrubis@suse.cz