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
I'm not sure whether you can set O_NONBLOCK on stdin, but select() or poll() will definitely get the job done.
select()
poll()