#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
void main()
{
pid_t pid=fork();
if(pid<0)
printf("创建进程失败\n");
else if(pid==0){
printf("创建子进程\n");
}else{
printf("this is father process\n");
waitpid(pid,0,0); // 等待子进程
}
}
#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
void main()
{
pid_t pid=fork();
if(pid<0)
printf("创建进程失败\n");
else if(pid==0){
printf("创建子进程\n");
}else{
printf("this is father process\n");
waitpid(pid,0,0); // 等待子进程
}
}