Commit | Line | Data |
---|---|---|
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" |
16 | fdflags \- set file and file descriptor flags | |
17 | .\" @fdflags | |
18 | .SH "SYNOPSIS" | |
19 | .nf | |
20 | .B "#include <mLib/fdflags.h>" | |
21 | ||
2b1924c2 MW |
22 | .ds mT \fBint fdflags( |
23 | .BI "\*(mTint " fd , | |
24 | .BI "\h'\w'\*(mT'u'unsigned " fbic ", unsigned " fxor , | |
25 | .BI "\h'\w'\*(mT'u'unsigned " fdbic ", unsigned " fdxor ); | |
aab9ab9f | 26 | .fi |
27 | .SH "DESCRIPTION" | |
28 | .B fdflags | |
29 | is a convenience function for setting file and file descriptor flags | |
30 | using | |
31 | .BR fcntl (2). | |
32 | .PP | |
33 | The file flags are read using | |
34 | .BR F_GETFL , | |
35 | the 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 | |
47 | and the result written back using | |
48 | .BR F_SETFL . | |
49 | .PP | |
50 | Similarly the file descriptor flags are read using | |
51 | .BR F_GETFD , | |
52 | the 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 | |
64 | and the result written back using | |
65 | .BR F_SETFD . | |
66 | .PP | |
67 | If all went well, | |
68 | .B fdflags | |
69 | returns zero; if there was an error, \-1 is returned. | |
70 | .SH "EXAMPLES" | |
71 | To set the non-blocking and close-on-exec flags: | |
72 | .VS | |
73 | fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC); | |
74 | .VE | |
75 | To clear the non-blocking and close-on-exec flags: | |
76 | .VS | |
77 | fdflags(fd, O_NONBLOCK, 0, FD_CLOEXEC, 0); | |
78 | .VE | |
79 | .sp -1 | |
80 | .SH "SEE ALSO" | |
81 | .BR mLib (3). | |
82 | .SH "AUTHOR" | |
9b5ac6ff | 83 | Mark Wooding, <mdw@distorted.org.uk> |