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

Kay Sievers kay at vrfy.org
Tue Jul 16 05:00:40 PDT 2013


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.

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. :)

Kay


More information about the systemd-devel mailing list