I'm trying a simple test to kill a script from within its self. It doesn't seem to be working.
function testKill
{
PID=$$
kill $PID
echo hello!
}
When I run this function,
[....]$ testKill
hello!
It clearly doesn't kill the process. How do I make the process terminate before sending the echo command?
When I move this all into an external script, it terminates correctly if I call the script directly from the command line. However, if I make a function inside my .bash_profile and call the script from within that function, the script isn't killed and it prints instead. How do I integrate it into my .bash_profile?
This is a minimal working example to use in a more complicated script.
sleep 1
to give the signal handler chance to receive the signal before running the echo ?kill $$
, this works and is A WHOLE LINE shorter!