#include<sys/types.h> //对于此程序而言此头文件用不到
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char ** argv )
{
pid_t pid = fork();
if (pid < 0)
fprintf(stderr, "error!");
else if( 0 == pid )
{
printf("This is the child process!");
_exit(0);
}
else
{
printf("This is the parent process! child process id = %d", pid);
}
//可能需要时候wait或waitpid函数等待子进程的结束并获取结束状态
exit(0);
}