Sign in
cobalt
/
cobalt
/
579fd3d94490c679e9ed2edd8e43e3473f383544
/
.
/
third_party
/
musl
/
src
/
misc
/
login_tty.c
blob: f0be0a09a35533519dbdf4a65c76a895c3ce34e5 [
file
] [
log
] [
blame
]
#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
;
}