Skip to contentSkip to conversation

A fork-like C-wrapper for clone()?

DISCUSSION Francesc Oller 1 participant 1 message Apr 6, 2001

lore
Share & tools
lore
#0 lore raw

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