patch: sv check should wait when svrun is not ready

From: Buck Evan <>
Date: Mon, 9 Feb 2015 17:55:19 -0800

Essentially, if `sv check` is run too soon after `runsv` (or runit for that
matter), it will immediately fail without waiting for runsv to come up. In
my particular use case, runit is running inside a (detached) docker, and
I'm using `sv check` to wait for my dockerized service to be ready, which I
think is a good use case for `sv check`. Without this patch, I'm forced to
write some code which re-runs `sv check` if it fails before $SVWAIT
seconds, which sounds awfully like the behavior of sv-check itself.

You can demonstrate the problem I'm trying to describe like so:

rm -rf myservice
mkdir -p myservice
ln -s /bin/cat myservice/run
./runsv ./myservice/ >&/dev/null & ./sv check ./myservice/; echo $?; ./sv
check ./myservice/; echo $?


$ ./demo
warning: ./myservice/: unable to open supervise/ok: file does not exist
ok: run: ./myservice/: (pid 65635) 0s


--- src/sv.c
+++ src/sv.c
_at__at_ -213,7 +213,7 @@ int checkscript() {
 int check(char *a) {
   unsigned int pid;

- if ((r =svstatus_get()) == -1) return(-1);
+ if ((r =svstatus_get()) == -1) return(0);
   while (*a) {
     if (r == 0) { if (*a == 'x') return(1); return(-1); }
     pid =(unsigned char)svstatus[15];
Received on Tue Feb 10 2015 - 01:55:19 UTC

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