#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
pid_t pid1;
pid_t pid2;
pid1 = fork();
pid2 = fork();
printf("pid1:%d, pid2:%d\n", pid1, pid2);
}
使用gcc编译,
问题1 此程序运行期间最多有几个进程?
4个进程, 这在我的一篇博客有讲
fork遇上for循环
问题2
已知其中一个进程 打印结果是
pid1: