日期:2014-05-16 浏览次数:21087 次
//fork()
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int main()
{
pid_t child_pid;
child_pid=fork();
switch(child_pid)
{
case -1:
printf("Create process failed!\n");
break;
case 0:
printf("Child process with ID : %d .\n",(int)getpid());
break;
default:
printf("Parent process with ID : %d ,Child process ID : %d .\n",(int)getpid(),(int)child_pid);
break;
}
return 0;
}