http://www.perlmonks.org?node_id=63413


in reply to patricide / matricide

Try the builtin getppid.

Update:
I just looked at what you're doing more closely, and I'm a bit curious about how you intend to guarantee that your kill call actually gets executed. A crafty user (if there are any trying to subvert your desires), could potentially interrupt or kill your script before it gets to the end, leaving them with an open shell. If your script is such that they'll never get the opportunity to do something like that, then you'll be fine. But just in case, you may want to toss in some signal handlers (e.g. SIGINT, SIGKILL, etc) that kills the shell as well.