Linux: Checking if a socket/pipe is broken without doing a read()/write()

前端 未结 3 643
暖寄归人
暖寄归人 2021-02-09 10:45

I have a simple piece of code that periodically writes data to a fd that\'s passed to it. The fd will most likely be a pipe or socket but could potentially be anything. I can de

3条回答
  •  生来不讨喜
    2021-02-09 11:42

    Try with select and its errorfds parameter:

    int **select**(int nfds, fd_set *restrict readfds,
          fd_set *restrict writefds, **fd_set *restrict errorfds**,
          struct timeval *restrict timeout);
    

提交回复
热议问题