PDA

View Full Version : clone() in freebsd?


boykomac
June 9th, 2010, 07:57
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
June 22nd, 2010, 08:18
First thing that pops into my mind is rfork(2)

darkshadow
June 23rd, 2010, 07:02
http://www.freebsd.org/cgi/man.cgi?query=rfork&apropos=0&sektion=0&manpath=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
June 23rd, 2010, 07:44
Yep. Sadly the linuxthreads port does not compile on FreeBSD 8.0, so no solution yet.