#!/usr/bin/perl -w @programs=("gkrellm", "xclock"); $SIG{'CHLD'} = sub { wait(); }; while (1) { # running programs foreach $p (@programs) { if (system("pidof $p >/dev/null 2>&1") != 0) { $retval=fork(); if ($retval == 0) { exec "$p &"; exit; } } } sleep(1); }