#!/usr/bin/perl my $kidpid; if ( !defined( $kidpid = fork() ) ) { #fork returned undef, so failed die "Cannot fork: $!"; } elsif ( $kidpid == 0 ) { # fork returned 0, so this branch is child exec("xterm -e top"); # if exec fails, fall through to the next statement die "can't exec : $!"; } else { # fork returned 0 nor undef # so this branch is parent sleep(5); my $result = kill "TERM", $kidpid; print "Killed child process $kidpid (result $result)\n"; sleep(5); }
In reply to Re: Controlling Child Processes
by zentara
in thread Controlling Child Processes
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |