diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-02-25 14:33:19 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-03-24 17:04:20 +0100 |
commit | 9a88f7da453eadc72d8f333700dbd80777feecd1 (patch) | |
tree | 8a096e37123ece1d20bcb4d0ae8e064bdd39747a /initd/setup_tty.c |
Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/setup_tty.c')
-rw-r--r-- | initd/setup_tty.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/initd/setup_tty.c b/initd/setup_tty.c new file mode 100644 index 0000000..cec663b --- /dev/null +++ b/initd/setup_tty.c @@ -0,0 +1,23 @@ +#include <unistd.h> +#include <fcntl.h> +#include <stdio.h> + +#include "init.h" + +int setup_tty(void) +{ + int fd; + + fd = open("/dev/console", O_WRONLY | O_NOCTTY); + if (fd < 0) { + perror("/dev/console"); + return -1; + } + + close(STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + dup2(fd, STDERR_FILENO); + + close(fd); + return 0; +} |