my $pidChild;
my $pid0=fork();
if ($pid0) {
#parent process
$pidChild=$pid0;
print "Parent has launched child $pid0\n";
sleep(10);
my $killed=kill 'KILL', $pidChild;
if ($killed) {
print "Parent has killed child $pid0\n";
}
sleep(5);
my @alive=`ps aux | grep process | grep -v grep`;
print "@alive\n";
}
else {
#child
print "This is child $$\n";
my $command='sh /path/process.sh';
exec($command);
}
####
my $pidChild;
my $pid0=fork();
if ($pid0) {
#parent process
$pidChild=$pid0;
print "Parent has launched child $pid0\n";
sleep(10);
my $killed=kill 'KILL', $pidChild;
if ($killed) {
print "Parent has killed child $pid0\n";
}
sleep(5);
my @alive=`ps aux | grep process | grep -v grep`;
print "@alive\n";
}
else {
#child
print "This is child $$\n";
my $command='sh /path/process.sh 2>&1';
exec($command);
}
####
my $command='sh /path/process.sh > /pathlogs/mylog.log';