brintos

brintos / llvm-project-archived public Read only

0
0
Text · 472 B · 8fa1d37 Raw
28 lines · c
1// RUN: %clang %s -o %t && %run %t2 3#define _GNU_SOURCE4#define _XOPEN_SOURCE 6005 6#include <assert.h>7#include <fcntl.h>8#include <stdlib.h>9#include <string.h>10#include <unistd.h>11 12int main() {13  int pt = posix_openpt(O_NOCTTY);14  if (pt == -1)15    return 0;16  char *s = ptsname(pt);17  assert(s);18  assert(strstr(s, "/dev"));19 20  char buff[1000] = {};21  int r = ptsname_r(pt, buff, sizeof(buff));22  assert(!r);23  assert(strstr(buff, "/dev"));24 25  close(pt);26  return 0;27}28