How to interrupt a fread call?

后端 未结 6 1352
暗喜
暗喜 2021-01-18 13:19

I have the following situation:

There is a thread that reads from a device with a fread call. This call is blocking as long as there is no data send from the device.

6条回答
  •  半阙折子戏
    2021-01-18 13:49

    Take a look at man 2 kill. (Or see here)

    I get the feeling that you don't want to do this, though--most of the time people ignore errno EINTR and read again. You might want to look into non-blocking reads instead.

提交回复
热议问题