From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp3.mail.ru (smtp3.mail.ru [94.100.179.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 182534696CA for ; Tue, 14 Apr 2020 14:38:55 +0300 (MSK) From: Alexander Turenko Date: Tue, 14 Apr 2020 14:38:17 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 08/12] popen: fix close-on-exec flag setting List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org fcntl(2) lists flags that can be set using F_SETFL: O_CLOEXEC is not included there. F_SETFD should be used to set close-on-exec. Parent's end of pipes are closed explicitly in a child process anyway. However this change fixes closing of the copy of a logger fd. See commit 07a07b3cc7b85375d20b3fc6ca1e5060304f337b ('popen: decouple logger fd from stderr') for more information why this file descriptor was introduced. Part of #4031. --- src/lib/core/popen.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/core/popen.c b/src/lib/core/popen.c index 4d57cd41e..1733e5131 100644 --- a/src/lib/core/popen.c +++ b/src/lib/core/popen.c @@ -638,8 +638,8 @@ make_pipe(int pfd[2]) diag_set(SystemError, "Can't create pipe"); return -1; } - if (fcntl(pfd[0], F_SETFL, O_CLOEXEC) || - fcntl(pfd[1], F_SETFL, O_CLOEXEC)) { + if (fcntl(pfd[0], F_SETFD, FD_CLOEXEC) || + fcntl(pfd[1], F_SETFD, FD_CLOEXEC)) { int saved_errno = errno; diag_set(SystemError, "Can't unblock pipe"); close(pfd[0]), pfd[0] = -1; @@ -899,9 +899,9 @@ popen_new(struct popen_opts *opts) say_debug("popen: duplicate logfd: %d", log_fd); if (log_fd < 0) return NULL; - if (fcntl(log_fd, F_SETFL, O_CLOEXEC) != 0) { + if (fcntl(log_fd, F_SETFD, FD_CLOEXEC) != 0) { diag_set(SystemError, - "Unable to set O_CLOEXEC on temporary logfd"); + "Unable to set FD_CLOEXEC on temporary logfd"); close(log_fd); return NULL; } -- 2.25.0