*nix select and exceptfds/errorfds semantics

前端 未结 2 1844
予麋鹿
予麋鹿 2020-12-01 13:53

The select syscall takes 3 filedescriptor sets for watching fds for readable/writeable and \"exceptions\" on filedescriptor.

My select man page doesn\'t state much a

2条回答
  •  忘掉有多难
    2020-12-01 14:10

    You're right, it depends on the type of device you're referencing with the file descriptors. So, it's different for sockets, FIFOs, serial ports, etc...

    Look at the man page for read(). At the bottom (at least in OS X) it lists the different errors you can get for different devices. Same goes for write().

    For sockets, FIFOs and other IPC mechanisms, I would check out Unix Network Programming, Volumes 1 and 2. IIRC it describes what kind of errnos to expect for different error conditions.

    I walked this path once with FIFOs. I ended up brainstorming all the ways the producer and consumer could interact with each end of the FIFO and then wrote test cases for each of those situations. It was a good (although tedious) way to discover all the different error conditions. I learned a lot though and ultimately the code just works now.

提交回复
热议问题