[systemd-devel] Unbuffered stderr for my systemd service?

WANG Chao chaowang at redhat.com
Tue Jul 16 10:34:37 PDT 2013

On 07/16/13 at 02:00pm, Kay Sievers wrote:
> On Tue, Jul 16, 2013 at 5:30 AM, WANG Chao <chaowang at redhat.com> wrote:
> > On 07/15/13 at 10:46pm, Lennart Poettering wrote:
> >> On Mon, 15.07.13 17:56, WANG Chao (chaowang at redhat.com) wrote:
> >>
> >> > I have a service (a script) running under systemd and need its stderr to
> >> > be output'd immediately, not line buffered. I tried serveral ways but
> >> > didn't work out. I hope to get some feedback here :)
> >>
> >> This is not supported. Logging doesn't deal in individual
> >> characters, really, but in log lines. Syslog doesn't do that, and
> >> neither does the Journal.
> >>
> >> And we will never support that, as allowing this would require us to
> >> always store the context a character was printed in so that lines could
> >> later be reassembled. But we cannot really do that.
> >>
> >> So, I fear I have to tell you that this is not supported and never
> >> will...
> >
> > I understand that. Record the context of a character is printed would
> > never be a good idea. But still, I feel pity about line buffered stderr
> > stream in Journal :(
> It is the right thing to buffer just buffer them to full lines.

Yes. Or buffer wouldn't be called "buffer".

> For the kernel counterpart, we added unbuffered console magic to the
> kernel. It is really nasty and broken hack and really makes not much
> sense in th eend. The code does work in the most common case, but just
> does stupid things as soon as things start to compete about the log.
>  http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=084681d14e429cb6192262ac7437f00e2c02f26a
>  http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=eab072609e11a357181806ab5a5c309ef6eb76f5
> Pretending to support pushing "animations" through a log system is a
> pretty bad idea and relies on technical promises nobody can really
> hold without inventing something that isn't logging anymore. But we
> have that already, it's the console. :)

I couldn't agree more. Log system can't really record "animations" in a
common way. So in my case, console is right thing to use. Thanks for
your information here. Have a good day!


More information about the systemd-devel mailing list