Use *_FILENO instead of hardcoding constants

This commit is contained in:
sin 2014-04-14 11:22:28 +01:00
parent fc4dc81535
commit 4d7091cae9
1 changed files with 4 additions and 7 deletions

View File

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