stdout of check script (change proposal)

From: <tomas.volf_at_showmax.com>
Date: Wed, 16 Oct 2019 09:03:54 +0200

Hello,

I would like to propose a small change in runit.

I was surprised by the way runit executes the check script.
Looking at the current sources from the tarball (2.1.2), I've
noticed that stdout is closed before check script gets execve'd:

admin/runit-2.1.2/src/sv.c:
    195 if (!pid) {
    196 prog[0] ="./check";
    197 prog[1] =0;
    198 close(1);
    199 execve("check", prog, environ);

Perhaps there's some motivation I don't know? I would propose
one of the following:

    a) keep both stdout and stderr open,
    b) close both stdout and stderr,
    c) if we don't care about the output, dup2 both to /dev/null.

The current behavior can be a bit confusing. For example, we
exec 2>&1 in most of our run-files so that output of the entire
script is logged with svlogd. If you attempt to do that in the
check file, the script will crash (because FD 1 is closed) and
if you're using dash, you won't even get an error message (that's
another bug to be fixed which was discovered while debugging the
check script issue).

a) has the advantage of seeing the output of the check script
when issuing commands on the terminal.

If we can agree on a solution, we are more than happy to provide
a patch for this.

Big thanks for runit!

Regards
W.

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.



Received on Wed Oct 16 2019 - 07:03:54 UTC

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