... Maybe this is not the right forum for bash/sh but what's the harm in asking :)
Yes, this is not a bash forum, and all in all, bash configuration is a rather complex topic...
Anyhow, the easiest approach would probably be to add a line
trap "kill 0" EXIT
to your a.sh. This sets up an exit handler which kills the current process group.
Then run a.sh in a new process group (so you avoid killing the calling Perl script, too):
my $x=`exec perl -e "setpgrp; exec '/root/a.sh'"`;
(I'm not aware of any way to create a new process group from within the shell script itself, so I'm using Perl's setpgrp here.)
In reply to Re^3: parent process stuck in read(2) on pipe opened to child process using backtick
by Eliya
in thread parent process stuck in read(2) on pipe opened to child process using backtick
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |