I definitely have a deadlock problem with Shepherd and I do believe I've found 
it.
shepherd 1.0.3

This is in service-controller when the service has been stopped:
(when logger
  (put-message logger 'terminate))
But in service-builtin-logger, this is called every time a line is read:
(or pid
    (and service
         (eq? 'running (service-status service))
         (match (service-running-value service)
           ((? process? process)
            (process-id process))
           (value
            value))))

service-status -> service-control-message -> put-message to the service
The fibers documentation says put-message is blocking. Surely this is a 
deadlock.

The value of `pid' can be cached and we might avoid the deadlock.
But this happens ONLY if a line of output is read while the service is 'running.
If output only comes while the service is 'starting/'stopping, we will keep 
calling service-status.

Potential fix:
At the time spawn-service-builtin-logger is called in fork+exec-command, we 
already know the pid.
Maybe just prepend the pid to the `command' argument if you want it to appear 
in the log output.




Reply via email to