NAME

Process::Child::Leash - to make sure the child process wont get lost with their parent.

DESCRIPTION

Here is the issue. The parent process is a wrapping bash script around the real process (child). If we stopped the wrapper script. The real process ( child ) will be still remained and running as normal.

How to terminal the parent process and the child process would be stopped as a chain reaction?

 +
 |--run.sh
   |
   |-- perl script.pl

This module will keep an eye on the parent process. When the parent is gone. It will remove the the real process ( child ).

USAGE

ATTACH IT WITHIN THE CODE

 #!/usr/bin/perl
 use strict;
 use warnings;
 use Process::Child::Leash;

 ... start of the script ...

 ## run.sh
 #!/bin/bash
 export SOMETHING=FOOBAR
 perl script.pl

 >> bash run.sh

USE IT OUTSIDE THE CODE

 ## run.sh
 #!/bin/bash
 export SOMETHING=FOOBAR
 perl -MProcess::Child::Leash script.pl

 >> bash run.sh

TIMEOUT THE HANGING PROCESS

Timeout after 10 seconds running.

 ## run.sh
 #!/bin/bash
 export CHILD_LEASH_TIMEOUT=10
 export DBIC_TRACE=1
 perl -MProcess::Child::Leash script.pl
 perl -MProcess::Child::Leash=timeout,10 script.pl

 >> bash run.sh

THEN WHAT?

get the pid of run.sh, and kill -9 that pid.

The script.pl process will be terminated.