supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: Guillermo <gdiazhartusch@gmail.com>
To: Supervision <supervision@list.skarnet.org>
Subject: Re: s6 problems logging
Date: Sun, 27 Jan 2019 16:35:48 -0300	[thread overview]
Message-ID: <CADQ2Nw8m8Ucu5LsnPxP5NMpObDRB+T-PpUe39Gh5OSj=0tMKmw@mail.gmail.com> (raw)
In-Reply-To: <20190127135646.66682ee5@zonker.seanm.ca>

Hello,

El dom., 27 ene. 2019 a las 15:56, Sean MacLennan escribió:
>
> So it seems that s6-log does not like buffered output.

It probably isn't that it doesn't like it, but that it doesn't even
get to see the output. As Jonathan also pointed out, when you run
doorknob using a supervision suite, stdout is redirected to a pipe,
which is not an 'interactive device' (unlike an interactive shell's
controlling terminal) so it is fully buffered. And at least GNU libc's
implementation of the <stdio.h> interface buffers indeed. A smaller
program that does your vprintf() + putchar('\n') sequence exhibits
this behaviour, and adding an fflush(stdout) call solves it. But...

> I modified
> doorknob to vsnprintf into a buffer and then tried various output
> methods.
>
> 1. puts(msg) Failed as expected (basically the same as vprintf).
>
> 2. write(1, msg, strlen(msg)) Worked! So non-buffered ok.
>
> 3. fputs(msg, stderr) Then add `fdmove -c 2 1' to the run file works!
>    So fdmove seems to fix things up. Which is probably why most people
>    don't see this problem.
>
> Obviously, for 2 and 3 I did a strcat(msg, "\n").
>
> So I think I will go with 2, but to stderr to follow Jonathan de Boyne
> Pollard's comment "Unix conventions: Logs go to standard error".

If you want minimal changes and follow the convention of logging to
stderr, you could have done vfprintf(stderr, fmt, ap) + fputc('\n',
stderr), which also works. stderr is never fully buffered.

G.


  parent reply	other threads:[~2019-01-27 19:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-27  3:15 Sean MacLennan
2019-01-27  5:20 ` Colin Booth
2019-01-27 16:47   ` Sean MacLennan
2019-01-27 17:56     ` Laurent Bercot
2019-01-27 18:13     ` Colin Booth
2019-01-27 18:56     ` Sean MacLennan
2019-01-27 19:27       ` Roger Pate
2019-01-28 11:00         ` Peter Pentchev
2019-02-01  9:22           ` Jonathan de Boyne Pollard
2019-01-27 19:35       ` Guillermo [this message]
2019-01-27 14:39 ` smaclennan/doorknob Jonathan de Boyne Pollard
2019-02-02 18:32   ` smaclennan/doorknob Sean MacLennan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADQ2Nw8m8Ucu5LsnPxP5NMpObDRB+T-PpUe39Gh5OSj=0tMKmw@mail.gmail.com' \
    --to=gdiazhartusch@gmail.com \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).