study/C_C++/sources/linux/test2.c

17 lines
297 B
C
Executable File

#include <stdio.h>
#include <unistd.h>
int main(void)
{
pid_t pid;
printf("father \n");
printf("fork \n");
pid = fork();
if(!pid)
printf("child \n");
else if(pid>0)
printf("i m the parent ,child pid %d\n",pid);
else
printf("fork failed \n");
}