sending crtl-c to a pid
Posted on 2012-09-06
I have a script I didn't write that when you issue ctrl-c it traps and then runs some other clean up code.
If I run the scritp ./debug & (at the command line)
then issue: kill -2 PID
it kills the script the same way it does by hitting crtl-c
But if I execute the script from another script and run: kill -2 PID, it doesn't work.
I tried -INT -SIGINT, SIGUSR1 and I can kill the pid but the script doesn't do it's cleanup which creates a tgz of all the output files.
So how can I kill this script gracefully and make it think it received a regular old ctrl-c or kill -2 PID?
This is what the test.sh script looks like right now:
echo $PID " is the pid you are looking for"
kill -2 $PID
remember kill -2 works fine from the command line only if I execute the .debug script from the command line. But it breaks when I launch it from another bash script.