aboutsummaryrefslogtreecommitdiff
path: root/tests/unistd/isatty.c
blob: 191036e933328cda06715736095eb328a43b2dba (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
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main() {
  int err;

  err = isatty(-1);
  assert(!err);
  assert(errno == EBADF);

  err = isatty(open("/dev/stdin", O_RDONLY));
  assert(err == 1);

  err = isatty(open("/dev/null", O_RDONLY));
  assert(!err);

  err = isatty(open("/dev", O_RDONLY));
  assert(!err);

  puts("success");

  return EXIT_SUCCESS;
}