From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2469 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Guillermo Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: s6 problems logging Date: Sun, 27 Jan 2019 16:35:48 -0300 Message-ID: References: <20190126221517.70ea00b8@zonker.seanm.ca> <20190127052000.4skktmkfzmit6ykl@cathexis.xen.prgmr.com> <20190127114751.169d2a15@zonker.seanm.ca> <20190127135646.66682ee5@zonker.seanm.ca> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="116675"; mail-complaints-to="usenet@blaine.gmane.org" To: Supervision Original-X-From: supervision-return-2059-gcsg-supervision=m.gmane.org@list.skarnet.org Sun Jan 27 20:36:02 2019 Return-path: Envelope-to: gcsg-supervision@m.gmane.org Original-Received: from alyss.skarnet.org ([95.142.172.232]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gnqDo-000UBJ-G9 for gcsg-supervision@m.gmane.org; Sun, 27 Jan 2019 20:36:00 +0100 Original-Received: (qmail 10583 invoked by uid 89); 27 Jan 2019 19:36:26 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Original-Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 10576 invoked from network); 27 Jan 2019 19:36:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=9K5vggdIZG0QxQMTryQEHSdyZAp3mrnjfCxS9PAVwME=; b=VmrPDwJ5RIE1uDjR2+F3b1hFlQv+bwo23DUacDe4reBWTGrAMFuBqWspVg7MZX2OVB ic9nnFpIMZpz+WQaDIizhgxSfvyxeUvRyuiD8VWLNQ9OwL6aPgCHJsWyhMeg/URsPXOE KcP28CNjeHdOybBrjemWSGBWWstk81E14hu2YfTxKfsdyAwRFMEmp5TGNvqCP4b8NZin 3WXQ8COp0Tfs/L7YMWd03UsGvghphOy+Nl+OwcLSRg6FujiQ+weDw0lcOQMpfWYJRQjx w0Rlojd0fh/dyIlWR7IE5Zg+jYNVAvyQ2qaSJqM0EL+47ic8c5/o+r0Dej4kUduMuPFe ypOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=9K5vggdIZG0QxQMTryQEHSdyZAp3mrnjfCxS9PAVwME=; b=O5xk6AIGIWpVxyszib0ZMSP3fs98KjDoo9uEOouZaeTB24+jCQ5ddRD2KzCg250IpA /6exCdwgqb8njJFcCxv6haVXzSrhR4p26Kvg7w52hesg16PLxN18Do0o+X+5ArE/tu1S LL55PqcQNJ4TAjAYnF8KFjIZGPWhLk4vCwHVn4mZZoOgViz1/pfXOLjQ1byyO8akdJUO r4azZkGw9c+iUhp0DGByzlgOE5tZbpc6s8bb3wgQiQPZ3BjsmDlj5VBZ2vHeb2XUygNQ 3+RAjG+7CoSYJLVLlnnRELNOELcpDnpF0WmjRko0Pxdqjo/v3G2Opydu9J5kzDiE3uBG xIhg== X-Gm-Message-State: AJcUukcZGS619g9uRYvRvhjF/hexzjtD/UZrmNanc4i+MR74feGpoZBQ Aad1oF6wdwJEaq7B88YyoIkZCk/cfe825UaMGkNm0A== X-Google-Smtp-Source: ALg8bN7IxzilThaL0U4iq387zGbzWd/byYVUC0SnyeL9It9oAS/J/0GDMSP6fzJv7vrL9eomNYVEHjKHCfLIcPP6kRE= X-Received: by 2002:a24:878c:: with SMTP id f134mr8800608ite.81.1548617758501; Sun, 27 Jan 2019 11:35:58 -0800 (PST) In-Reply-To: <20190127135646.66682ee5@zonker.seanm.ca> Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2469 Archived-At: Hello, El dom., 27 ene. 2019 a las 15:56, Sean MacLennan escribi=C3=B3: > > 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 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.