summaryrefslogtreecommitdiff
path: root/initd/setup_tty.c
blob: cec663bc57f0ea0d5cb5fe55f5721c1fe4684070 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}