supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: "Laurent Bercot" <ska-supervision@skarnet.org>
To: "Dewayne Geraghty" <dewayne.geraghty@heuristicsystems.com.au>,
	supervision@list.skarnet.org
Subject: Re: s6-log problem with +regex
Date: Fri, 10 May 2019 02:38:14 +0000	[thread overview]
Message-ID: <em83b64206-0f16-4001-89b8-cc00424acf37@elzian> (raw)
In-Reply-To: <1fd4f712-f743-68ff-f648-151004ecfb0b@heuristicsystems.com.au>

>Thank-you for s6-rc and friends.  I came across two items:
>1. the s6-log in testing requires a control directive. In my testing
>without a T, t, n $VALUE for example, the s6-log command failed.

"s6-log 1", which does nothing but send stdin straight through to
stdout, works for me on both Linux and FreeBSD. 1 is an action
directive. So, I cannot reproduce what you're reporting here.


>2. The regular expression preceded by a + unintentionally matches
>everything, which was surprising as I intended to maintain separate logs
>  which emanated from the same process (apache24)

I can absolutely reproduce what you're reporting here, but the
match is intentional. :) By default, every line is selected; if you
want to do a positive matching, you have to first deselect everything:

>#!/usr/local/bin/execlineb -P ; # The testing script
>redirfd -r 0 /tmp/af
>/usr/local/bin/s6-log -b n3 +^\\\[ /tmp/date-only  f s100 S1500 T
>/tmp/default

Your +^\[ regular expression does nothing here because every line
is already selected, so everything goes into /tmp/default.
A "-" directive before the "+^\\\[" directive should deselect
every line, and then your matching expression will work as you
intend.


>The platform is amd64 FreeBSD 11.2Stable built May 6, clang v7.0.0 and
>clang 8.0.0

That is not a factor in the problem above. However, it *is* a factor
in the following issue:

>PS I haven't made sense of the hyphen in the example, after "E500 - " on
>page https://www.skarnet.org/software/s6/s6-log.html.  Testing resulted in
>s6-log: fatal: unrecognized directive: -

Now that is interesting. It appears that the BSD libc's regcomp()
does not support empty regular expressions: the directive "-" fails
with that error message on FreeBSD, OpenBSD and NetBSD. Whereas on
Linux (with either musl or glibc), an empty regular expression is
accepted by regcomp() and treated as always matching.

So, you found a portability problem; thanks for the report. I will
patch s6-log so that an empty regular expression is recognized even
on the BSDs - so "-" will always deselect everything and "+" will
always select everything.

In the meantime, on Free/Open/NetBSD (and likely Darwin too),
please use "-.*" as a way to deselect every line at the beginning
of a s6-log script.

--
Laurent



  parent reply	other threads:[~2019-05-10  2:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10  1:02 Dewayne Geraghty
2019-05-10  2:27 ` Guillermo
2019-05-10  2:38 ` Laurent Bercot [this message]
2019-05-10  4:52   ` Dewayne Geraghty
2019-05-10 14:23     ` Laurent Bercot

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=em83b64206-0f16-4001-89b8-cc00424acf37@elzian \
    --to=ska-supervision@skarnet.org \
    --cc=dewayne.geraghty@heuristicsystems.com.au \
    --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).