summaryrefslogtreecommitdiff
path: root/static/v10/man4/fd.4
blob: 29890d84ac56cf23eb7fb19f19ffc675bb03f9ec (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
.TH FD 4
.CT 2 file_io 
.SH NAME
fd, stdin, stdout, stderr, tty \- file descriptor files
.SH DESCRIPTION
These files, conventionally called
.BR /dev/fd/\^0 ", " /dev/fd/1 ", ... " /dev/fd/127 ,
refer to files accessible through file descriptors.
If file descriptor
.I n
is open,
these two system calls have the same effect:
.IP
.EX
fd = open("/dev/fd/\fIn\fP", mode);
fd = dup(\fIn\fP\^);
.EE
.LP
On these devices
.I creat
(see
.IR open (2))
is equivalent to
.I open,
and
.I mode
is ignored.
As with
.IR dup ,
subsequent reads or writes on
.I fd
fail unless the original file descriptor
allows the operations.
.SH FILES
.TF /dev/stdout
.TP
.F /dev/fd/*
.TP
.F /dev/stdin
linked to
.F /dev/fd/0
.TP
.F /dev/stdout
linked to
.F /dev/fd/1
.TP
.F /dev/stderr
linked to
.F /dev/fd/2
.TP
.F /dev/tty
linked to
.F /dev/fd/3
.SH SEE ALSO
.IR open (2), 
.IR dup (2)
.SH DIAGNOSTICS
.I Open
returns \-1
and
.B EBADF
if the related file descriptor is not open
and in the appropriate mode (reading or writing).