3 .\" Manual for file descriptor flags
5 .\" (c) 1999, 2001, 2005, 2009, 2023, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH fdflags 3mLib "23 July 1999" "Straylight/Edgeware" "mLib utilities library"
34 .\"--------------------------------------------------------------------------
36 fdflags \- set file and file descriptor flags
38 .\"--------------------------------------------------------------------------
42 .B "#include <mLib/fdflags.h>"
44 .ta \w'\fBint fdflags('u
45 .BI "int fdflags(int " fd ,
46 .BI " unsigned " fbic ", unsigned " fxor ,
47 .BI " unsigned " fdbic ", unsigned " fdxor );
50 .\"--------------------------------------------------------------------------
54 is a convenience function for setting file and file descriptor flags
58 The file flags are read using
60 the new flags are calculated as
72 and the result written back using
75 Similarly the file descriptor flags are read using
77 the new flags calculated as
89 and the result written back using
94 returns zero; if there was an error, \-1 is returned.
96 .\"--------------------------------------------------------------------------
99 To set the non-blocking and close-on-exec flags:
101 fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
103 To clear the non-blocking and close-on-exec flags:
105 fdflags(fd, O_NONBLOCK, 0, FD_CLOEXEC, 0);
109 .\"--------------------------------------------------------------------------
114 .\"--------------------------------------------------------------------------
117 Mark Wooding, <mdw@distorted.org.uk>
119 .\"----- That's all, folks --------------------------------------------------