in reply to Re^4: Killing a child processin thread Killing a child process
kill $pid;
The first argument to kill should be the signal, not the PID. Since you didn't test the return value of kill you haven't spotted the error.