mirror of
git://git.musl-libc.org/musl
synced 2024-12-15 11:15:07 +00:00
add login_tty function
This commit is contained in:
parent
0217ed72f9
commit
4b2cb37770
@ -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"
|
||||
|
||||
|
14
src/misc/login_tty.c
Normal file
14
src/misc/login_tty.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user