首页 > 系统服务 > 详细

linux打开进程数测试

时间:2018-10-20 11:19:22      阅读:157      评论:0      收藏:0      [点我收藏+]

查看linux默认打开最大打开进程数

具体参考:https://www.jb51.net/article/143667.htm

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAXPROCESS 65535
#define SLEEPTIME 60
int 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);
}

  

linux打开进程数测试

原文:https://www.cnblogs.com/shansongxian/p/9820858.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!