From patchwork Tue May 17 15:00:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jo-Philipp Wich X-Patchwork-Id: 623153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r8LGh0Npcz9t6B for ; Wed, 18 May 2016 01:05:00 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2gX5-0004L6-1f; Tue, 17 May 2016 15:03:39 +0000 Received: from mxout01.bytecamp.net ([212.204.60.217]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b2gWy-0004CM-VH for lede-dev@lists.infradead.org; Tue, 17 May 2016 15:03:36 +0000 Received: by mxout01.bytecamp.net (Postfix, from userid 1001) id 7FF1930FE54; Tue, 17 May 2016 17:01:09 +0200 (CEST) Received: from mail.bytecamp.net (mailstore.bytecamp.net [212.204.60.20]) by mxout01.bytecamp.net (Postfix) with ESMTP id 1EEA130FE7D for ; Tue, 17 May 2016 17:01:09 +0200 (CEST) Received: (qmail 36632 invoked by uid 89); 17 May 2016 17:01:07 +0200 Received: from unknown (HELO localhost.localdomain) (jo%wwsnet.net@213.61.250.148) by mail.bytecamp.net with AES128-SHA encrypted SMTP; 17 May 2016 17:01:07 +0200 From: Jo-Philipp Wich To: lede-dev@lists.infradead.org Date: Tue, 17 May 2016 17:00:46 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160517_080333_217177_D21E0047 X-CRM114-Status: UNSURE ( 9.04 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.204.60.217 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 4/5] inittab: use patch_stdio() for stdio redirection X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jo-Philipp Wich , john@phrozen.org MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Jo-Philipp Wich --- inittab.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/inittab.c b/inittab.c index f8f0218..622601a 100644 --- a/inittab.c +++ b/inittab.c @@ -93,22 +93,14 @@ static int dev_exist(const char *dev) static void fork_worker(struct init_action *a) { - int fd; pid_t p; a->proc.pid = fork(); if (!a->proc.pid) { p = setsid(); - fd = dev_open(a->id); - if (fd != -1) - { - dup2(fd, STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - dup2(fd, STDERR_FILENO); - if (fd > STDERR_FILENO) - close(fd); - } + if (patch_stdio(a->id)) + ERROR("Failed to setup i/o redirection\n"); ioctl(STDIN_FILENO, TIOCSCTTY, 1); tcsetpgrp(STDIN_FILENO, p);