The only thing you're allowed to do after calling vfork()
is execute a file. It's right in the documentation:
The
vfork()
function shall be equivalent tofork()
, except that the behavior is undefined if the process created byvfork()
either modifies any data other than a variable of type pid_t used to store the return value fromvfork()
, or returns from the function in whichvfork()
was called, or calls any other function before successfully calling_exit()
or one of theexec
family of functions.... > The use of
vfork()
for any purpose except as a prelude to an immediate call to a function from theexec
family, or to_exit()
, is not advised.
To wit, the only legal calls are _exit
and exec*
.