blob: 177bec67d9dc11dd7eff0e233566c0ec1e7f02dd (
plain) (
blame)
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
36
37
38
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <clset.h>
include <fset.h>
# XISATTY -- Test if the given file is a terminal.
int procedure xisatty (fd)
int fd # file descriptor of candidate device
int epa, epa_tt, epa_ty
extern zgettt(), zgetty()
int fstati(), clstati()
begin
# If we are a connected subprocess, the referenced file is a standard
# stream, and i/o has not been redirected, assume that the file behaves
# as a terminal.
if (clstati(CL_PRTYPE) == PR_CONNECTED)
if (fd == STDIN || fd == STDOUT || fd == STDERR)
if (fstati (fd, F_REDIR) == NO)
return (YES)
else
return (NO)
# Otherwise, the use of the terminal driver tells us if the file is
# open on a terminal device.
epa = fstati (fd, F_DEVICE)
call zlocpr (zgettt, epa_tt)
call zlocpr (zgetty, epa_ty)
if (epa == epa_tt || epa == epa_ty)
return (YES)
else
return (NO)
end
|