Return-Path: Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by mail.openembedded.org (Postfix) with ESMTP id 0DA6C7F8B2 for ; Sun, 19 Jan 2020 04:12:15 +0000 (UTC) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.2) with ESMTPS id 00J4CEUt003854 (version=TLSv1 cipher=AES256-SHA bits=256 verify=FAIL); Sat, 18 Jan 2020 20:12:14 -0800 (PST) Received: from pek-lpg-core2.corp.ad.wrs.com (128.224.153.41) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.468.0; Sat, 18 Jan 2020 20:12:13 -0800 From: To: , Date: Sun, 19 Jan 2020 12:12:11 +0800 Message-ID: <1579407131-338324-1-git-send-email-mingli.yu@windriver.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579405812-336202-1-git-send-email-mingli.yu@windriver.com> References: <1579405812-336202-1-git-send-email-mingli.yu@windriver.com> MIME-Version: 1.0 Cc: pavelmn@axis.com Subject: [PATCH v2] Open file with O_CLOEXEC to avoid fd leak X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2020 04:12:16 -0000 Content-Type: text/plain From: Pavel Modilaynen Use close-on-exec (O_CLOEXEC) flag when open log file to make sure its file descriptor is not leaked to parent process on fork/exec. Signed-off-by: Mingli Yu --- pseudo_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pseudo_util.c b/pseudo_util.c index c867ed6..0ec527b 100644 --- a/pseudo_util.c +++ b/pseudo_util.c @@ -1594,7 +1594,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) { } free(filename); } - fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT, 0644); + fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644); if (fd == -1) { pseudo_diag("help: can't open log file %s: %s\n", pseudo_path, strerror(errno)); } else { -- 2.7.4