提交 4b2cb377 编写于 作者: F Felix Janda 提交者: Rich Felker

add login_tty function

上级 0217ed72
......@@ -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"
......
#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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册