From c23a1b2568eca5329c01fde0b426664a39a4f8a7 Mon Sep 17 00:00:00 2001 From: Jamesits Date: Wed, 27 Dec 2023 11:56:55 +0800 Subject: [PATCH] fix exec_* startup delay if ulimit nofile is too high --- ngx_rtmp_exec_module.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ngx_rtmp_exec_module.c b/ngx_rtmp_exec_module.c index fccd4ba70..63e157ab9 100644 --- a/ngx_rtmp_exec_module.c +++ b/ngx_rtmp_exec_module.c @@ -778,13 +778,8 @@ ngx_rtmp_exec_run(ngx_rtmp_exec_t *e) /* close all descriptors but pipe write end */ maxfd = sysconf(_SC_OPEN_MAX); - for (fd = 0; fd < maxfd; ++fd) { - if (fd == pipefd[1]) { - continue; - } - - close(fd); - } + close_range(0, pipefd[1] - 1, 0); + close_range(pipefd[1] + 1, maxfd - 1, 0); fd = open("/dev/null", O_RDWR);