1 | // RUN: %clang %s -o %t && %run %t |
---|---|
2 | |
3 | #define _GNU_SOURCE |
4 | #define _XOPEN_SOURCE 600 |
5 | |
6 | #include <assert.h> |
7 | #include <fcntl.h> |
8 | #include <stdlib.h> |
9 | #include <string.h> |
10 | #include <unistd.h> |
11 | |
12 | int main() { |
13 | int pt = posix_openpt(O_NOCTTY); |
14 | if (pt == -1) |
15 | return 0; |
16 | char *s = ptsname(fd: pt); |
17 | assert(s); |
18 | assert(strstr(s, "/dev")); |
19 | |
20 | char buff[1000] = {}; |
21 | int r = ptsname_r(fd: pt, buf: buff, buflen: sizeof(buff)); |
22 | assert(!r); |
23 | assert(strstr(buff, "/dev")); |
24 | |
25 | close(fd: pt); |
26 | return 0; |
27 | } |
28 |