#include <stdio.h>
#include <unistd.h>
int main()
{
pid_t pid;
pid_t pid2;
pid_t retpid;
pid = getpid();
printf("before fork:id = %d\n",pid);
retpid = fork();
//fork返回值大于0就是父进程(而这个大于0的值刚好是子进程的pid) fork返回值等于0就是子进程
pid2 = getpid();
printf("after fork:id =%d\n",pid2);
if(pid == pid2){
printf("this is father :retpid=%d\n",retpid);
}
else if(pid != pid2){
printf("this is child :retpid=%d,pid=%d\n",retpid,pid2);
}
return 0;
}```