7 /* set/clear non-blocking flag
9 /* #include <iostuff.h>
11 /* int non_blocking(int fd, int on)
13 /* the \fInon_blocking\fR() function manipulates the non-blocking
14 /* flag for the specified open file, and returns the old setting.
20 /* For non-blocking I/O, specify a non-zero value (or use the
21 /* NON_BLOCKING constant); for blocking I/O, specify zero
22 /* (or use the BLOCKING constant).
24 /* The result is non-zero when the non-blocking flag was enabled.
26 /* All errors are fatal.
30 /* The Secure Mailer license must be distributed with this software.
33 /* IBM T.J. Watson Research
35 /* Yorktown Heights, NY 10598, USA
38 /* System interfaces. */
43 /* Utility library. */
48 /* Backwards compatibility */
50 #define PATTERN FNDELAY
52 #define PATTERN O_NONBLOCK
55 /* non_blocking - set/clear non-blocking flag */
57 int non_blocking(fd
, on
)
63 if ((flags
= fcntl(fd
, F_GETFL
, 0)) < 0)
64 msg_fatal("fcntl: get flags: %m");
65 if (fcntl(fd
, F_SETFL
, on
? flags
| PATTERN
: flags
& ~PATTERN
) < 0)
66 msg_fatal("fcntl: set non-blocking flag %s: %m", on
? "on" : "off");
67 return ((flags
& PATTERN
) != 0);