@@@ man wip
[mLib] / sys / 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
adec5584
MW
22.ta \w'\fBint fdflags('u
23.BI "int fdflags(int " fd ,
24.BI " unsigned " fbic ", unsigned " fxor ,
25.BI " unsigned " fdbic ", unsigned " fdxor );
aab9ab9f 26.fi
27.SH "DESCRIPTION"
28.B fdflags
29is a convenience function for setting file and file descriptor flags
30using
31.BR fcntl (2).
32.PP
33The file flags are read using
34.BR F_GETFL ,
35the new flags are calculated as
36.sp 1
37.RS
38.I new-flags
39=
40.BI ( old-flags
41.B &
42.BI ~ fbic )
43.B ^
44.I fxor
45.RE
46.sp 1
47and the result written back using
48.BR F_SETFL .
49.PP
50Similarly the file descriptor flags are read using
51.BR F_GETFD ,
52the new flags calculated as
53.sp 1
54.RS
55.I new-flags
56=
57.BI ( old-flags
58.B &
59.BI ~ fdbic )
60.B ^
61.I fdxor
62.RE
63.sp 1
64and the result written back using
65.BR F_SETFD .
66.PP
67If all went well,
68.B fdflags
69returns zero; if there was an error, \-1 is returned.
70.SH "EXAMPLES"
71To set the non-blocking and close-on-exec flags:
72.VS
73fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
74.VE
75To clear the non-blocking and close-on-exec flags:
76.VS
77fdflags(fd, O_NONBLOCK, 0, FD_CLOEXEC, 0);
78.VE
79.sp -1
80.SH "SEE ALSO"
81.BR mLib (3).
82.SH "AUTHOR"
9b5ac6ff 83Mark Wooding, <mdw@distorted.org.uk>