summaryrefslogtreecommitdiff
path: root/src/unistd/isatty.c
blob: f544d8d6ca738ce490214a950ba4c58adbbc8d6f (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
29
30
#include <sys/types.h>
#include <unistd.h>
#include <termios.h>

/** test for a terminal device **/

int isatty(int fildes)
{
	struct termios tios;
	if (tcgetattr(fildes, &tios) == 0) {
		/* errno set by tcgetattr() */
		#if 0
		errno = EBADF;	/* ARGUMENT(fildes) is not a valid file descriptor */
		errno = ENOTTY;	/* ARGUMENT(fildes) is not associated with a terminal */
		#endif
		return 1;
	}
	return 0;
}

/***
checks whether the file descriptor ARGUMENT(fildes) is associated with a
terminal device.
***/

/*
RETURN(ZERO, ARGUMENT(fildes) is not a terminal)
RETURN(ONE, ARGUMENT(fildes) is a terminal device)
POSIX(1)
*/