Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As I understand it, you can fclose(stdin) without issue on almost all POSIX systems.


Sure, but it's surprising, and in code, 'surprising' usually translates to 'wrong'.


Yes, 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.


In old sysvinit-style daemons, closing stdin/stdout/stderr (or redirecting them to /dev/null) was a necessary part of the daemon initialization process.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: