forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisatty.c
More file actions
35 lines (27 loc) · 718 Bytes
/
isatty.c
File metadata and controls
35 lines (27 loc) · 718 Bytes
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
/*
* Copyright 2011 The Emscripten Authors. All rights reserved.
* Emscripten is available under two separate licenses, the MIT license and the
* University of Illinois/NCSA Open Source License. Both these licenses can be
* found in the LICENSE file.
*/
#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;
}