How to check if stdin is still opened without blocking?

后端 未结 5 575
野性不改
野性不改 2021-01-02 00:57

I need my program written in pure C to stop execution when stdin is closed.

There is indefinite work done in program main cycle, and there is no way I can use blocki

5条回答
  •  无人及你
    2021-01-02 01:40

    I'm not sure whether you can set O_NONBLOCK on stdin, but select() or poll() will definitely get the job done.

提交回复
热议问题