Bug 1212756 - Service cannot write to /dev/stdout
Summary: Service cannot write to /dev/stdout
Keywords:
Status: CLOSED CANTFIX
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 21
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-17 09:50 UTC by Jaroslav Škarvada
Modified: 2015-06-17 23:25 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-06-17 23:25:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
service (703 bytes, text/x-csrc)
2015-04-17 09:50 UTC, Jaroslav Škarvada
no flags Details
corresponding unit file (148 bytes, text/plain)
2015-04-17 09:51 UTC, Jaroslav Škarvada
no flags Details

Description Jaroslav Škarvada 2015-04-17 09:50:18 UTC
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.

Comment 1 Jaroslav Škarvada 2015-04-17 09:51:10 UTC
Created attachment 1015507 [details]
corresponding unit file

Comment 2 Jaroslav Škarvada 2015-04-17 11:51:11 UTC
Bash:
/dev/stdout -> /proc/self/fd/1 -> /dev/pts/X

Systemd:
/dev/stdout -> /proc/self/fd/1 -> socket:[Y]

Comment 3 Jaroslav Škarvada 2015-04-17 11:55:48 UTC
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.

Comment 4 Lennart Poettering 2015-06-17 23:25:16 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.