Can anyone give me an actual example of how to do this:
The normal return value from fcntl with this command is a nonnegative number which can be interpreted as the bitwise OR of the individual flags. Since the file access modes are not single-bit values, you can mask off other bits in the returned flags with O_ACCMODE to compare them.
eg, given flags=fcntl(fd,F_GETFL); "flags" is 2050.
also: once I've set O_NONBLOCK, how do I unset it?