From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C0EC3138335 for ; Tue, 19 Jun 2018 21:34:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A31C1E092D; Tue, 19 Jun 2018 21:34:34 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 606F3E092D for ; Tue, 19 Jun 2018 21:34:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CBE2F335C97 for ; Tue, 19 Jun 2018 21:34:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1E0C22DA for ; Tue, 19 Jun 2018 21:34:29 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1529434756.47e4bfae57402eedd017d6098b432c2c411cd374.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/rc-pipes.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 47e4bfae57402eedd017d6098b432c2c411cd374 X-VCS-Branch: master Date: Tue, 19 Jun 2018 21:34:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: bb75a6d0-99d0-4b70-b383-4e1139b709d3 X-Archives-Hash: 6752cc2dc8d2c7a32bbd3476b71a1c49 commit: 47e4bfae57402eedd017d6098b432c2c411cd374 Author: William Hubbs gmail com> AuthorDate: Tue Jun 19 18:59:16 2018 +0000 Commit: William Hubbs gentoo org> CommitDate: Tue Jun 19 18:59:16 2018 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=47e4bfae fix gcc 7 warnings in pipe routines src/rc/rc-pipes.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/rc/rc-pipes.c b/src/rc/rc-pipes.c index 2d7b623e..70fefa80 100644 --- a/src/rc/rc-pipes.c +++ b/src/rc/rc-pipes.c @@ -37,21 +37,20 @@ int rc_pipe_command(char *cmd) return -1; pid = fork(); - if (pid < 0) - return -1; - else if (pid > 0) { + if (pid > 0) { /* parent */ - close(pfd[0]); + close(pfd[pipe_read_end]); return pfd[pipe_write_end]; } else if (pid == 0) { /* child */ close(pfd[pipe_write_end]); - if (pfd[0] != STDIN_FILENO) { - if (dup2(pfd[0], STDIN_FILENO) < 0) + if (pfd[pipe_read_end] != STDIN_FILENO) { + if (dup2(pfd[pipe_read_end], STDIN_FILENO) < 0) exit(1); - close(pfd[0]); + close(pfd[pipe_read_end]); } execl("/bin/sh", "sh", "-c", cmd, NULL); exit(1); } + return -1; }