2001-04-06 11:38:55

by Francesc Oller

[permalink] [raw]
Subject: A fork-like C-wrapper for clone()?

Hi all!

is there a fork-like C-wrapper for clone which would let write
something like:

if ((pid=clone(0,SIGCHLD|CLONE_VM))==0) /* child */
{
child_code;
_exit(0);
}
else
{
assert(pid>0); /* mother */
mother_code;
exit(0);
}

I'm not thinking in glibc'__clone or Linus' clone.c example since
they encapsulate the main thread code in a function. (i.e. not
fork-like)

Can somebody point me to some sample code?

I'll thank a CC to my e-mail

cheers

Francesc Oller