From: Willy Tarreau Date: Thu, 21 Feb 2019 21:22:06 +0000 (+0100) Subject: MINOR: checks: use my_closefrom() to close all FDs X-Git-Tag: v2.0-dev1~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2555ccf4d08e5cab6756690753eb08ac0761facd;p=thirdparty%2Fhaproxy.git MINOR: checks: use my_closefrom() to close all FDs Instead of looping on all FDs, let's use my_closefrom() which does it respecting the current process' limits and possibly doing it more efficiently. --- diff --git a/src/checks.c b/src/checks.c index e4c7a4896d..6d7b6aa271 100644 --- a/src/checks.c +++ b/src/checks.c @@ -1970,8 +1970,7 @@ static int connect_proc_chk(struct task *t) /* close all FDs. Keep stdin/stdout/stderr in verbose mode */ fd = (global.mode & (MODE_QUIET|MODE_VERBOSE)) == MODE_QUIET ? 0 : 3; - while (fd < global.rlimit_nofile) - close(fd++); + my_closefrom(fd); environ = check->envp; extchk_setenv(check, EXTCHK_HAPROXY_SERVER_CURCONN, ultoa_r(s->cur_sess, buf, sizeof(buf)));