Skip to content

runsv locks up after service's directory is removed and recreated (xbps-install -f) #25

@0x5c

Description

@0x5c

When the service's directory is removed and recreated, like during an xbps package reinstall, runsv will enter a broken state. Once in that state, a command to down the service will cause runsv to terminate the supervised process, but will fail to update the status file and possibly more, soft-locking.

The same bug happens for the log service if present, but presence of a log service is not needed.

Minimal reproducer

This can be done as a normal user

  1. Have a <service> directory containing solely a run file and a supervise -> ../supervise symlink.

    #!/bin/sh
    
    exec 2>&1
    exec <some command here>
  2. From the parent directory, run runsv <service>

  3. Copy delete, and recreate <service>

  4. From the same dir as step 2, run SVDIR=$(pwd) sv stop <service>

  5. The supervised process will stop but the sv command will fail on timeout, reporting the supervised process' PID as the one it had before being terminated.
    Repeating the stop command will continue to fail and report that same invalid PID.
    Trying to start the service will immediately 'succeed', reporting the same PID.

I recommend using as the supervised process a program that outputs frequently, makes it easier to see when the supervised process is running/stopped. I using a simple binary that prints an incremented number each second.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions