summaryrefslogtreecommitdiff
path: root/src/misc/login_tty.c
blob: f0be0a09a35533519dbdf4a65c76a895c3ce34e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <utmp.h>
#include <sys/ioctl.h>
#include <unistd.h>

int login_tty(int fd)
{
	setsid();
	if (ioctl(fd, TIOCSCTTY, (char *)0)) return -1;
	dup2(fd, 0);
	dup2(fd, 1);
	dup2(fd, 2);
	if (fd>2) close(fd);
	return 0;
}