chiark / gitweb /
Import buf from Catacomb; split out the dstr bits, and throw away the mp and
[mLib] / man / fdflags.3
CommitLineData
aab9ab9f 1.\" -*-nroff-*-
2.de VS
3.sp 1
4.RS
5.nf
6.ft B
7..
8.de VE
9.ft R
10.fi
11.RE
12.sp 1
13..
fbf20b5b 14.TH fdflags 3 "23 July 1999" "Straylight/Edgeware" "mLib utilities library"
aab9ab9f 15.SH "NAME"
16fdflags \- set file and file descriptor flags
17.\" @fdflags
18.SH "SYNOPSIS"
19.nf
20.B "#include <mLib/fdflags.h>"
21
22.BI "int fdflags(int " fd ,
23.BI " unsigned " fbic ", unsigned " fxor ,
24.BI " unsigned " fdbic ", unsigned " fdxor );
25.fi
26.SH "DESCRIPTION"
27.B fdflags
28is a convenience function for setting file and file descriptor flags
29using
30.BR fcntl (2).
31.PP
32The file flags are read using
33.BR F_GETFL ,
34the new flags are calculated as
35.sp 1
36.RS
37.I new-flags
38=
39.BI ( old-flags
40.B &
41.BI ~ fbic )
42.B ^
43.I fxor
44.RE
45.sp 1
46and the result written back using
47.BR F_SETFL .
48.PP
49Similarly the file descriptor flags are read using
50.BR F_GETFD ,
51the new flags calculated as
52.sp 1
53.RS
54.I new-flags
55=
56.BI ( old-flags
57.B &
58.BI ~ fdbic )
59.B ^
60.I fdxor
61.RE
62.sp 1
63and the result written back using
64.BR F_SETFD .
65.PP
66If all went well,
67.B fdflags
68returns zero; if there was an error, \-1 is returned.
69.SH "EXAMPLES"
70To set the non-blocking and close-on-exec flags:
71.VS
72fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
73.VE
74To clear the non-blocking and close-on-exec flags:
75.VS
76fdflags(fd, O_NONBLOCK, 0, FD_CLOEXEC, 0);
77.VE
78.sp -1
79.SH "SEE ALSO"
80.BR mLib (3).
81.SH "AUTHOR"
9b5ac6ff 82Mark Wooding, <mdw@distorted.org.uk>