repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
include cleanups: remove unused headers and add feature test macros
[musl.git]
/
src
/
unistd
/
ctermid.c
blob
77684050e6f935c40d0b1937aa126b0aa5cb2930
1
#include <stdio.h>
2
#include <fcntl.h>
3
#include <unistd.h>
4
#include <limits.h>
5
#include
"syscall.h"
6
7
char
*
ctermid
(
char
*
s
)
8
{
9
static char
s2
[
L_ctermid
];
10
int
fd
;
11
if
(!
s
)
s
=
s2
;
12
*
s
=
0
;
13
fd
=
open
(
"/dev/tty"
,
O_WRONLY
|
O_NOCTTY
|
O_CLOEXEC
);
14
if
(
fd
>=
0
) {
15
ttyname_r
(
fd
,
s
,
L_ctermid
);
16
__syscall
(
SYS_close
,
fd
);
17
}
18
return
s
;
19
}