The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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 ...

USE IT OUTSIDE THE CODE

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

TIMEOUT THE HANGING PROCESS

Timeout after 10 seconds running.

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

 OR

 perl -MProcess::Child::Leash=timeout,10 script.pl