实验代码
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main (void)
{
int ret_from_fork;
ret_from_fork = vfork ();
if (ret_from_fork == -1)
{
perror ("vfork");
exit (-1);
}
else if (ret_from_fork == 0)
{
printf ("child process\n");
return 0;
//exit (0);
}
printf ("father process\n");
return 0;
}
执行结果: