procd: improve early console handling
[openwrt.git] / package / system / procd / patches / 0002-early-remove-superfluous-close-of-stdio-file-descrip.patch
1 From 1edd25cfa0a26dac1ca5d49bce479ebdea336437 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Fri, 19 Jul 2013 08:21:17 +0200
4 Subject: [PATCH 2/2] early: remove superfluous close of stdio file
5  descriptors
6
7 'man dup2' says:
8
9   dup2() makes newfd be the copy of oldfd, closing newfd first if
10   necessary, but note the following:
11
12   *  If oldfd is not a valid file descriptor, then the call fails,
13      and newfd is not closed.
14
15   *  If oldfd is a valid file descriptor, and newfd has the same
16      value as oldfd, then dup2() does nothing, and returns newfd.
17
18 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
19 ---
20  early.c |    4 ----
21  1 file changed, 4 deletions(-)
22
23 diff --git a/early.c b/early.c
24 index 204623b..f9e3277 100644
25 --- a/early.c
26 +++ b/early.c
27 @@ -53,10 +53,6 @@ static void early_console(const char *dev)
28                 mkdev("*console", 0600);
29  
30         dd = open(dev, O_RDWR);
31 -       close(STDIN_FILENO);
32 -       close(STDOUT_FILENO);
33 -       close(STDERR_FILENO);
34 -
35         if (dd < 0) {
36                 ERROR("Failed to open %s\n", dev);
37                 return;
38 -- 
39 1.7.10
40