#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/stat.h>
int main(void)
{
pid_t pid = fork();
if (pid < 0)
{
return 0;
}
if (pid > 0)
{
exit(0);
}
if (pid == 0)
{
int i = 0;
for (; i < 100; i++)
{
pid_t pid_tmp = fork();
if (pid_tmp < 0)
{
return 0;
}
if (pid_tmp == 0)
{
exit(0);
}
}
pause();
}
return EXIT_SUCCESS;
}
Linux编写一个孤儿进程,这个孤儿进程可以同时创建100个僵死进程。
最新推荐文章于 2024-03-05 20:59:58 发布