Subject: bug#56674: [Shepherd] Use of ‘waitpid’, ‘system*’, etc. in service code can cause deadlocks

From: Maxime Devos <[email-masked]>
Date: Sat, 13 Aug 2022 16:59:55 +0200

On 21-07-2022 17:39, Ludovic Courtès wrote:
>> Alternatively:
>>
>> 4. Do the waitpid in a separate thread (needs work-around for the
>> multi-threaded fork problem, probably C things? Or modifying Guile and
>> maybe glibc to avoid async-unsafe things or make more things
>> async-safe or whatever the appropriate ...-safe is here.)
> For shepherd, multithreading is not an option due to the semantics of
> fork in the presence of threads.

 From what I've read, multi-threaded fork is safe as long as you do an 
exec 'immediately' afterwards, without doing things like taking locks or 
allocating memory with malloc in-between the fork and exec. I don't 
think it's possible to do that in Guile code, but that's what the C 
things are for.

Greetings,
Maxime.