1io_nonblock(3) Library Functions Manual io_nonblock(3)
2
3
4
6 io_nonblock - switch to non-blocking I/O
7
9 #include <io.h>
10
11 void io_nonblock(int64 fd);
12
14 io_nonblock puts UNIX descriptor fd into ``non-blocking mode.'' Calling
15 io_nonblock(fd) before io_fd(fd) makes io_tryread and io_trywrite
16 faster and more efficient.
17
18 Actually, current UNIX kernels do not support non-blocking descriptors;
19 they support non-blocking open files. Furthermore, many programs will
20 break if they encounter non-blocking mode. This means that you must not
21 use io_nonblock for a descriptor inherited from another program.
22
23 io_nonblock has no return value; it always succeeds. If d is not the
24 number of a UNIX descriptor, io_nonblock has no effect.
25
26 If io_fd is given a descriptor in blocking mode, io_tryread and io_try‐
27 write go through the following contortions to avoid blocking:
28
29
30 1 Stop if poll says that the descriptor is not ready. Otherwise
31 there's a good chance, but not a guarantee: even if poll says the
32 descriptor is ready, the descriptor might not be ready a moment
33 later. (Furthermore, poll can fail on some systems.)
34
35 2 Catch SIGALRM. SIGALRM must not be blocked, and must not be used
36 elsewhere in the program.
37
38 3 Set an interval timer so that any blocking call will be interrupted
39 by SIGALRM within 10 milliseconds. (Current UNIX kernels do not
40 allow any shorter interval.) Of course, this may still mean a
41 10-millisecond delay.
42
43 If io_fd is given a descriptor in non-blocking mode (or a descriptor
44 for a regular disk file), io_tryread and io_trywrite avoid these con‐
45 tortions.
46
48 io_wait(3), io_canwrite(3)
49
50
51
52 io_nonblock(3)