Linux select() vs ppoll() vs pselect()

后端 未结 4 414
旧巷少年郎
旧巷少年郎 2020-12-13 00:43

In my application, there is a io-thread, that is dedicated for

  1. Wrapping data received from the application in a custom protocol
  2. Sending the data+cust
4条回答
  •  一向
    一向 (楼主)
    2020-12-13 01:35

    The accepted answer is not correct vis a vis difference between select and pselect. It does describe well how a race condition between sig-handler and select can arise, but it is incorrect in how it uses pselect to solve the problem. It misses the main point about pselect which is that it waits for EITHER the file-descriptor or the signal to become ready. pselect returns when either of these are ready.Select ONLY waits on the file-descriptor. Select ignores signals. See this blog post for a good working example: https://www.linuxprogrammingblog.com/code-examples/using-pselect-to-avoid-a-signal-race

提交回复
热议问题