#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
pid_t pid;
if((pid = vfork()) < 0)
{
perror("vfork is failed");
exit(1);
}
else if(pid == 0)
{
printf("this is child process\n");
/*
exit(0);
*/
}
else
{
printf("this is parent process\n");
/*
if(wait(NULL) == -1)
{
perror("fail to wait");
exit(1);
}
*/
}
return 0;
}
$ ./vforkBaidu
this is child process
this is parent process
$ gcc -o vforkTest vforkTest.c
$ ./vforkTest
this is child process
this is parent process
Bus error
$