diff options
author | Felix Janda <felix.janda@posteo.de> | 2014-12-20 20:13:27 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-12-20 20:13:27 -0500 |
commit | 4b2cb37770e56835b261660535cea77474154ba0 (patch) | |
tree | 9e7c320ebb6770e76e0119fccc1cd8da4ac78f5c /src | |
parent | 0217ed72f986d78b177f1a014e93f2150105bb44 (diff) | |
download | musl-4b2cb37770e56835b261660535cea77474154ba0.tar.gz musl-4b2cb37770e56835b261660535cea77474154ba0.tar.bz2 musl-4b2cb37770e56835b261660535cea77474154ba0.tar.xz musl-4b2cb37770e56835b261660535cea77474154ba0.zip |
add login_tty function
Diffstat (limited to 'src')
-rw-r--r-- | src/misc/login_tty.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 <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; +} |