Date: Sat, 8 Jul 2023 17:09:32 +0100 From: David Chisnall <theraven@FreeBSD.org> To: Brooks Davis <brooks@freebsd.org> Cc: Yuri <yuri@freebsd.org>, Freebsd hackers list <freebsd-hackers@freebsd.org> Subject: Re: What is the equivalent of the linux system call clone() on FreeBSD? Message-ID: <1866F21E-9EBC-48C3-A4FC-76A87895A6F1@FreeBSD.org> In-Reply-To: <ZKiJZbzkA%2BaJkOeM@spindle.one-eyed-alien.net> References: <693faa01-ca5e-a71c-4e5c-aea4f505ce54@tsoft.com> <ZKiJZbzkA%2BaJkOeM@spindle.one-eyed-alien.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 7 Jul 2023, at 22:53, Brooks Davis <brooks@freebsd.org> wrote: > > clone is at least partially implemented in terms of rfork(2) flags. > It's not immediately obvious what the code is doing so I can't comment > if you'll be able to do what you need rfork if if you really need a > clone implementation. The Linux kernel doesn’t really have a notion of threads as distinct from processes. This leads to some really annoying things (the Linux equivalent of PROC_PDEATHSIG_CTL kills the child process when the parent thread exits, even if it is not the main thread in the parent process and the parent is still happily running). This means that clone (/ clone3) is not just standing in for rfork, it is also standing in for thr_new. Depending on exactly what you’re doing with clone, you may want one of: - rfork - pdfork - thr_new Unfortunately, rfork does not have a pdfork-like variant (yet) and so there are some combinations of rfork flags that don’t let you use process descriptors (procfds in Linux), whereas in Linux these are orthogonal. David
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1866F21E-9EBC-48C3-A4FC-76A87895A6F1>
