Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit cb71f43

Browse files
committed
blow up rlimit of process
NOFILE: 1000000:1000000 NPROC: 30604:30604 SIGPENGING: 30604:30604 Signed-off-by: Gao feng <omarapazanadi@gmail.com>
1 parent c72276b commit cb71f43

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/init.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <sys/types.h>
77
#include <sys/stat.h>
88
#include <sys/wait.h>
9+
#include <sys/resource.h>
910
#include <fcntl.h>
1011
#include <dirent.h>
1112
#include <sched.h>
@@ -1144,6 +1145,7 @@ static int hyper_loop(void)
11441145
struct epoll_event *events;
11451146
struct hyper_pod *pod = &global_pod;
11461147
sigset_t mask, omask;
1148+
struct rlimit limit;
11471149

11481150
sigemptyset(&mask);
11491151
sigaddset(&mask, SIGCHLD);
@@ -1162,6 +1164,26 @@ static int hyper_loop(void)
11621164
sigdelset(&omask, SIGCHLD);
11631165
signal(SIGCHLD, hyper_init_sigchld);
11641166

1167+
// setup open file limit
1168+
limit.rlim_cur = limit.rlim_max = 1000000;
1169+
if (setrlimit(RLIMIT_NOFILE, &limit) < 0) {
1170+
perror("set rlimit for NOFILE failed");
1171+
return -1;
1172+
}
1173+
1174+
// setup process num limit
1175+
limit.rlim_cur = limit.rlim_max = 30604;
1176+
if (setrlimit(RLIMIT_NPROC, &limit) < 0) {
1177+
perror("set rlimit for NPROC failed");
1178+
return -1;
1179+
}
1180+
1181+
// setup pending signal limit, same with NRPROC
1182+
if (setrlimit(RLIMIT_SIGPENDING, &limit) < 0) {
1183+
perror("set rlimit for SIGPENDING failed");
1184+
return -1;
1185+
}
1186+
11651187
ctl.efd = epoll_create1(EPOLL_CLOEXEC);
11661188
if (ctl.efd < 0) {
11671189
perror("epoll_create failed");

0 commit comments

Comments
 (0)