#!/usr/bin/perl -w
######################################################################
# process.pl
######################################################################
# Perl Power! - Michael Schilli 1998
######################################################################

use Process;

$myproc = Process->new();      # create new process object
$myproc->start("sleep 10") ||  # start sleep process
    die "Start: Error";        # error?

for($i=1; $i<=5; $i++) {       # periodically intrrogate process status
    if($myproc->poll()) {     
        print "Running\n";       # process avtive
    } else {
        print "Not running\n"; # process terminated
    }

    if($i==3) {                # in the third cycle ...
        $myproc->kill() ||     # terminate process
            die "Kill: Error";
    }

    sleep(1);                  # sleep until next round
}

