Good morning,
I've finally decided to try to find out why a running deamon was showing
up as
"failed" in the daily outputs.
Turns up it's because I had used regex special char in the daemon flags.
In this case it was a brace "{" which was unbalanced and cause rcctl to
fail :
doing rc_check
pgrep: bad expression: braces not balanced
(failed)
Looking at the code, it's here in /etc/rc.d/rc.subr :
180 rc_check() {
181 pgrep -T "${daemon_rtable}" -q -xf "${pexp}"
182 }
${pexp} is expanded properly and matches the ps output.
But pgrep interprets it as a regex, so the unbalanced brace becomes a
problem.
I've been unable to find a way to escape this brace to make pgrep work
and I
couldn't find any clue in the manpages on how to do that or if that's
even
supported.
I ended up doing things differently and putting most of the flags in
daemon
config file to workaround this issue, so everything's fine now, but if
someone
has clues how I could have done it via the flags, I'd love to learn
about it.
Anyway, wouldn't it be safer/easier here to have a flag telling pgrep to
interpret the expression as a fixed string rather than a regexp ?
Like a -F flag (similar to what grep uses) that would regcomp with
REG_NOSPEC
instead of REG_EXTENDED ?
I could try to write a patch to pkill if this change is something that
the
OpenBSD team deems useful.
Thanks, have a nice day
Arnaud