In another question I asked I realized I want to redirect stdin
but have it provide absolutely no input. For example, I want a call to getchar()
to hang forever. I would then like to terminate the application by sending a kill signal.
I tried freopen("/dev/null", "r", stdin);
but this does not work because /dev/null
when read returns an EOF
which it seems triggers the getchar()
to be executed, and my program is exited.
How can I redirect stdin
to not read from anything at all?