summaryrefslogtreecommitdiff
path: root/man/fd.3
blob: b22338d742cbd1aa7bc9923e10cdb4390f8a1ae9 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
.TH qlibs: fd 3
.SH NAME
fd \- duplicate, move or close a file descriptor
.SH SYNTAX
.B #include \(dqfd.h\(dq

int \fBfd_copy\fP(int \fIto\fR,int \fIfrom\fR);
.br
int \fBfd_move\fP(int \fIto\fR,int \fIfrom\fR);
.br
int \fBfd_coe\fP(int \fIfd\fR);
.SH DESCRIPTION
.B fd_copy
copies 
descriptor
.I from
to descriptor
.IR to .
If
.I to
was already open,
.B fd_copy
closes it.
.B fd_copy
always leaves
.I from
intact;
if
.I to
and
.I from
are the same number,
.B fd_copy
does nothing.
.B fd_copy
does not guarantee that
.I to
will remain open, if it was open, in case of error.

.B fd_move
moves
descriptor
.I from
to descriptor
.IR to .
If
.I to
was already open,
.B fd_move
closes it.
If the move is successful,
.B fd_move
closes
.IR from .
Exception:
if
.I to
and
.I from
are the same number,
.B fd_move
does nothing.

.B fd_coe
closes
.IR fd .
.SH "RETURN CODES"
.BR fd_copy ,
.BR fd_move ,
and
.B fd_coe
return 
.I 0 
on success, 
and 
.I -1 
on error.
.SH "SEE ALSO"
dup(2), fcntl(2)