blob: be66ccc002f377bcbca49d11f8d38d947e183cc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#if 0
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>
#include <stdio.h>
#include "_unistd.h"
#include "_syscall.h"
#ifndef readlink
#define readlink(_path, _buf, _bufsiz) __scall3(readlink, _path, _buf, _bufsiz)
#endif
char *ttyname(int fildes)
{
char path[PATH_MAX + 1];
static char __ttyname[PATH_MAX + 1];
if (!isatty(fildes)) {
return NULL;
}
sprintf(path, "/proc/self/fd/%d", fildes);
if (readlink(path, __ttyname, sizeof(__ttyname)) == -1) {
return NULL;
}
return __ttyname;
}
/*
POSIX(1)
*/
#endif
|