[LTP] [PATCH v3 2/2] Refactor exit_group01 using new API
Richard Palethorpe
rpalethorpe@suse.de
Thu Nov 16 14:24:36 CET 2023
Hello,
Cyril Hrubis <chrubis@suse.cz> writes:
> 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
+1
>
> 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.
OK, I looked again and it appears that indeed the thread group leader is
not reaped if there are threads in the group that are still alive
(wait_consider_task). Also it is only the thread group leader that can
enter a zombie state (exit_notify).
So this just leaves PID recycling as a potential issue IIRC.
--
Thank you,
Richard.
More information about the ltp
mailing list