# clone() in freebsd?



## boykomac (Jun 9, 2010)

Hello!

I am new to freebsd and I'm trying to "migrate" one of my linux applications.

The app spawns a child with clone() and the child has its own private mounts namespace - it mounts filesystems and when it "dies" the mounted filesystems are gone too (does not leave mounted filesystems behind).

I wonder what is the equivalent of clone() on freebsd as fork() gives the child no private namespace, but a shared one, and when the child dies it leaves mounted filesystems behind.

Thanks for your help!

Boyko


----------



## vdvluc (Jun 22, 2010)

First thing that pops into my mind is rfork(2)


----------



## darkshadow (Jun 23, 2010)

http://www.freebsd.org/cgi/man.cgi?...ath=FreeBSD+5.2-RELEASE+and+Ports&format=html

```
BUGS
     FreeBSD does not yet implement a native clone() library call, and the
     current pthreads implementation does not use rfork() with RFMEM.  A
     native port of the linux threads library, /usr/ports/devel/linuxthreads,
     contains a working clone() call that utilizes RFMEM.  The rfork_thread(3)
     function can often be used instead of clone().
```
it seem that freebsd a way behind :\


----------



## boykomac (Jun 23, 2010)

Yep. Sadly the linuxthreads port does not compile on FreeBSD 8.0, so no solution yet.


----------

