3 ms·
As I understand it, you can fclose(stdin) without issue on almost all POSIX systems.
by michael_h 12y ago
As I understand it, you can fclose(stdin) without issue on almost all POSIX systems.
- kazinator 12y agoYes, I know this, and in a throwaway little program where you are sure you are the last one to ever touch stdin (because you're calling exit right there in the loop, for instance) it is okay.
- derefr 12y agoIn old sysvinit-style daemons, closing stdin/stdout/stderr (or redirecting them to /dev/null) was a necessary part of the daemon initialization process.
- cbd1984 12y agoSure, but it's surprising, and in code, 'surprising' usually translates to 'wrong'.