MCPcopy Create free account
hub / github.com/GJDuck/e9patch / ttyname_r

Function ttyname_r

examples/stdlib.c:6016–6026  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6014}
6015
6016static int ttyname_r(int fd, char *buf, size_t buflen)
6017{
6018 char path[32];
6019 ssize_t r = snprintf(path, sizeof(path)-1, "/proc/self/fd/%d", fd);
6020 if (r < 0 || r >= (ssize_t)sizeof(path)-1)
6021 return errno;
6022 r = readlink(path, buf, buflen-1);
6023 if (r < 0)
6024 return (errno == ENAMETOOLONG? ERANGE: errno);
6025 return 0;
6026}
6027
6028static unsigned sleep(unsigned sec)
6029{

Callers

nothing calls this directly

Calls 2

snprintfFunction · 0.85
readlinkFunction · 0.85

Tested by

no test coverage detected