Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to manage a process with supervisord, but the process does not have an option to run in foreground: it always daemonizes. (That's Zabbix Server).

Is there any way to manage daemons with supervisor? Any tools which will make it run in foreground? Or maybe, use the pidfile somehow?

share|improve this question
up vote 6 down vote accepted

In order to deal with the problem, we'll need some program running in foreground, which exits whenever the daemon exits, and which also proxies signals to the daemon.

Consider using the following script bash script:

#! /usr/bin/env bash
set -eu


# Proxy signals
function kill_app(){
    kill $(cat $pidfile)
    exit 0 # exit okay
trap "kill_app" SIGINT SIGTERM

# Launch daemon
sleep 2

# Loop while the pidfile and the process exist
while [ -f $pidfile ] && kill -0 $(cat $pidfile) ; do
    sleep 0.5
exit 1000 # exit unexpected
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.