Discussion:
What is the equivalent of the linux system call clone() on FreeBSD?
(too old to reply)
Yuri
2023-07-07 20:45:53 UTC
Permalink
Linux has the clone() function that allows the caller more control over
process cloning than the fork(2) function does.

FreeBSD only has clone() in its Linux emulator code for Linux apps, but
it seems to be missing in the system.

Is there a library that implements functionality similar to Linux's clone()?

Otherwise, how can clone() calls like this
https://github.com/cea-hpc/wi4mpi/blob/master/src/common/helper.c#L82 be
resolved on FreeBSD?


Thanks,

Yuri




--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Cy Schubert
2023-07-07 21:31:59 UTC
Permalink
Post by Yuri
Linux has the clone() function that allows the caller more control over
process cloning than the fork(2) function does.
FreeBSD only has clone() in its Linux emulator code for Linux apps, but
it seems to be missing in the system.
Is there a library that implements functionality similar to Linux's clone()?
Otherwise, how can clone() calls like this
https://github.com/cea-hpc/wi4mpi/blob/master/src/common/helper.c#L82 be
resolved on FreeBSD?
Linux replaced fork() and pthread_create() with clone().
Post by Yuri
Thanks,
Yuri
--
Cheers,
Cy Schubert <***@cschubert.com>
FreeBSD UNIX: <***@FreeBSD.org> Web: https://FreeBSD.org
NTP: <***@nwtime.org> Web: https://nwtime.org

e^(i*pi)+1=0




--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Brooks Davis
2023-07-07 21:53:41 UTC
Permalink
Post by Yuri
Linux has the clone() function that allows the caller more control over
process cloning than the fork(2) function does.
FreeBSD only has clone() in its Linux emulator code for Linux apps, but
it seems to be missing in the system.
Is there a library that implements functionality similar to Linux's clone()?
Otherwise, how can clone() calls like this
https://github.com/cea-hpc/wi4mpi/blob/master/src/common/helper.c#L82 be
resolved on FreeBSD?
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.

-- Brooks


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
David Chisnall
2023-07-08 16:09:32 UTC
Permalink
Post by Brooks Davis
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



--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...