Luna/libc/src/utmp.cpp

23 lines
342 B
C++
Raw Permalink Normal View History

2023-11-25 11:18:25 +00:00
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#include <utmp.h>
extern "C"
{
int login_tty(int fd)
{
setsid();
if (ioctl(fd, TIOCSCTTY) < 0) return -1;
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
close(fd);
return 0;
}
}