Re: s6-log problem with +regex

From: Laurent Bercot <>
Date: Fri, 10 May 2019 02:38:14 +0000

>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

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

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

Received on Fri May 10 2019 - 02:38:14 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC