tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: using of fork() in multithreaded application



On 1/24/25 1:27 PM, Greg Troxel wrote:
Taylor R Campbell <riastradh%NetBSD.org@localhost> writes:

Date: Wed, 22 Jan 2025 16:47:13 +0100
From: Peter Skvarka <ps%softinengines.com@localhost>

I have two questions:
Is safe using of fork() in NetBSD 10.1 in mutlithreaded application ?

Generally yes, with the caveat that it is difficult for applications
to use correctly.

In 2010ish I saw a hard-to-find bug, the details of which are now fading
from memory.  I think it was some kind of lock taken in a routine that
was called after fork and before exec.  I think the program was python
and the lock was in libc's malloc. (This would have NetBSD 5 or 6.)

I've fixed various issues in libc to make fork-without-exec reasonable reliable for many use cases. malloc certainly was one of them.

Joerg


Home | Main Index | Thread Index | Old Index