I have an if-statement at the top of a C main method, which checks if STDIN is open. If it is open, the program prints an error and exits. This is mainly for documentation reasons. I don't want users of the program to assume passing things to STDIN is supported.
A problem arose when I tried to execute this program as a SystemD daemon, however.
It seems like SystemD programs always have an open STDIN pipe.
Why is this? Can it be avoided?
It's kinda bad if fd 0 isn't opened because the next open would result in fd 0 being used. It's therefore common to have it open, but reading from /dev/null
.