23 lines
342 B
C++
23 lines
342 B
C++
#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;
|
|
}
|
|
}
|