首页服务器Linux服务器 Linux创建进程达到65535的方法

Linux创建进程达到65535的方法

Linux上创建进程据说消耗很少,这个一直是Linux的特点,于是就专门测试Linux创建进程的极限,测试代码如下: //fork.c#include #include #include #include #define MAXPROCESS 6…

Linux上创建进程据说消耗很少,这个一直是Linux的特点,于是就专门测试Linux创建进程的极限,测试代码如下:

//fork.c#include #include #include #include #define MAXPROCESS 65535#define SLEEPTIME 60int main(int argc, char **argv) {  pid_t pid;  int count = 0;  int maxprocess = MAXPROCESS;  if (argc == 2) {    maxprocess = atoi(argv[1]);   }  for (count = 0; count < maxprocess; count++) {    pid = fork();    if (pid < 0) {      perror("fork error");      exit(1);    } else if (pid == 0) {      printf("child %d start/n", count);      sleep(SLEEPTIME);      printf("child %d end/n", count);      exit(0);    }     printf("parent:create %d child/n", count);  }  for (count = 0; count < MAXPROCESS; count++) {    wait();  }  exit(0);}
本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/fwq/Linux/9426.html
上一篇详解linux系统下pid的取值范围
下一篇 Linux定时备份数据库到指定邮箱的方法
admin

作者: admin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部