in reply to running program?

Here's a simple launcher daemon,

#!/usr/bin/perl use Proc::Daemon; Proc::Daemon::Init; my @args = qw/whatever/; while (1) { defined (my $cpid = fork) or sleep(10), next; $cpid and wait, next; exec '/path/to/PROGRAM', @args; exit -1; }
That forks off a child instance of PROGRAM. The parent sleeps until awakened (that's what wait does) by SIGCHLD, which says PROGRAM has exited. Then the parent does it all over again. The exit call after exec is a safety in case exec fails. Without it, the daemon becomes a fork bomb when it can't find or execute PROGRAM for some reason.

You may want to do something a little different based on how PROGRAM ends itself. Just assign the list return of wait to an array and decode according to the docs.

Like any daemon, this is an independent cuss -- you have to signal it with kill or system /bin/kill to make it stop. You can log out of the system and this will keep on chugging along.

After Compline,
Zaxo