shamu has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to figure out how to kill a child process after a timeout has occurred, where the child runs a Java app.
I have a program script.pl, that forks a child which calls 'exec' on a shellscript.sh which ends with 'exec $JAVA_BIN $OPT class "${1+$@}"'. The 'exec' call is supposed to replace the shell of the child so that it can be killed from the parent process after a timeout. However, the java process seems to disconnect itself from the execution chain and is not killed.
When I run the script.pl, the process tree looks like:
script.pl(27177)---sh(27180)---java(27181)-+-{java}(27186)
|-{java}(27187)
|-{java}(27188)
`-{java}(27271)
When I run shellscript.sh directly, the process tree looks like:
java(26855)-+-{java}(26860)
|-{java}(26861)
|-{java}(26864)
`-{java}(26871)
The child executes the process this way...
my @cmd = ($SCRIPT,'arg1'); exec(@cmd) or croak "Unable to execute @cmd: $!";
How can I call 'exec' on the script so if killed, the java app is killed?
Is the only way to make this work, calling the java app directly from the perl exec call?
Thanks Monks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling exec on exec
by jettero (Monsignor) on Sep 19, 2008 at 19:31 UTC | |
by shamu (Acolyte) on Sep 19, 2008 at 20:02 UTC | |
by ikegami (Patriarch) on Sep 19, 2008 at 20:11 UTC | |
|
Re: Calling exec on exec
by sflitman (Hermit) on Sep 22, 2008 at 00:33 UTC |