ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 4d7091cae915b64e0c9d9dce6d45a5ed3e4dd622
parent fc4dc81535007e4854b97b3f681b8c80ce041fa4
Author: sin <sin@2f30.org>
Date:   Mon, 14 Apr 2014 11:22:28 +0100

Use *_FILENO instead of hardcoding constants

Diffstat:
Mswitch_root.c | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/switch_root.c b/switch_root.c @@ -110,16 +110,13 @@ main(int argc, char **argv) /* if -c is set, redirect stdin/stdout/stderr to console */ if (console) { - close(0); - if(open(console, O_RDWR) == -1){ + close(STDIN_FILENO); + if(open(console, O_RDWR) == -1) eprintf("open %s:", console); - } - if (dup2(0,1) == -1){ + if (dup2(STDIN_FILENO, STDOUT_FILENO) != STDOUT_FILENO) eprintf("dup2 %s:", "0,1"); - } - if (dup2(0,2) == -1){ + if (dup2(STDIN_FILENO, STDERR_FILENO) != STDERR_FILENO) eprintf("dup2 %s:", "0,2"); - } } /* execute init */