From: Felix Janda Date: Sun, 21 Dec 2014 01:13:27 +0000 (-0500) Subject: add login_tty function X-Git-Tag: v1.1.6~13 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4b2cb37770e56835b261660535cea77474154ba0;p=oweals%2Fmusl.git add login_tty function --- diff --git a/include/utmp.h b/include/utmp.h index e9ba23e2..24e2da7b 100644 --- a/include/utmp.h +++ b/include/utmp.h @@ -35,6 +35,8 @@ void setutent(void); void updwtmp(const char *, const struct utmp *); +int login_tty(int); + #define _PATH_UTMP "/dev/null/utmp" #define _PATH_WTMP "/dev/null/wtmp" diff --git a/src/misc/login_tty.c b/src/misc/login_tty.c new file mode 100644 index 00000000..f0be0a09 --- /dev/null +++ b/src/misc/login_tty.c @@ -0,0 +1,14 @@ +#include +#include +#include + +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; +}