1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-05 12:17:10 +01:00
init/initd/setup_tty.c
David Oberhollenzer 9a88f7da45 Initial commit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
2018-03-24 17:04:20 +01:00

23 lines
317 B
C

#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;
}