You might just run a script like this as your daemon:
Code:
#!/bin/bash
function daemon_loop()
{
false #<-- replace with daemon stuff (perhaps exec daemon $*)
}
while ( daemon_loop $* ); do
sleep 1
done
This will restart the daemon when it exits unless it exits with an error. You'd need to make the actual daemon exit without error when given e.g. the
SIGHUP signal to indicate that it should be restarted.
Kevin Barry
PS Another option is to design it to work with
xinetd, which won't actually start it until a connection is made; there will be one fork per connection.