Created attachment 1015506 [details] service Description of problem: It seems that systemd service cannot write to /dev/stdout. It can see it, check it for R/W access rights (by access call), but cannot write to it. Reproducer is attached. Version-Release number of selected component (if applicable): systemd-216-24.fc21.x86_64 How reproducible: always Steps to Reproduce: 1. Install the attached reproducer 2. systemctl start ytest 3. systemctl status ytest Actual results: ... unable to open /dev/stdout ... Expected results: No error Additional info: I came across this problem when making unit file for one daemon. It has option for filename where to log. As I wanted it to log to stdout/journal, I used /dev/stdout. It works correctly if it is run without systemd.
Created attachment 1015507 [details] corresponding unit file
Bash: /dev/stdout -> /proc/self/fd/1 -> /dev/pts/X Systemd: /dev/stdout -> /proc/self/fd/1 -> socket:[Y]
I cannot find a way how to make glibc "open" call to use STDOUT under systemd. AFAIK open("/dev/stdout", ... has been used for this.
Yeah, the kernel does not support opening /proc/self/fd/1 if that is a socket. It only supports that for fifos, ttys, files and a few others. systemd connects stdout/stderr of all services with the journal, to collect the output. In the shell use ">&2" in place of ">/dev/stderr" to echo something to stderr. Alternatively, use StandardOutput=null to turn of journal collection. Basically, the idiom >/dev/stderr is not really compatible with many execution contexts. This is unlikely to change, sorry. I have now added a TODO list item to document this behaviour in the systemd docs for StandardOutput= though.