SUMMARY: killing one's own shell

From: Christopher L. Barnard (
Date: Wed Nov 03 1999 - 13:10:03 CST

I asked:

> We have a script in some monitoring software that should kill the shell
> that it is in when it finishes. Right now the last line is to do a
> "kill -9" on the parent ID of the shell script, but that generates an
> error in the monitoring software (it is tripped by the -9 flag to kill).
> A regular kill, an exit, a logout, having this script called by another
> script that does a regular kill or exit, have all been tried and do not
> work. Is there any other way to have a shell script kill the shell in
> which it is running?

The solution:

I received several suggestions, which I have forwarded on to the group that
has been having this problem. Despite my repeated requests to find out how
things went, the idea of a summary to a mailing list is just too foreign I
guess. So I'm sending out this summary with the suggestions, but I do not
have the information about whether on not these worked.

The recommendations that involved any sort of "kill" was rejected out of hand,
because my understanding is that these have all been tried and none of them
worked. I also got the recommendation to make sure the shell starts with the
shell name (of course) with the -f flag.

Most folks, however, recommended running the script like this "exec"
instead of just "". That is what I have recommended.

Thanks to:
agony <>
Roger Fujii <>
Karl Baker <>
"A jannu" <>
"Neill, Mark" <>
Patrice ALLAIS <>
David Foster <>
Peter Polasek <>
"Brion Leary" <>
Jochen Bern <>
"S. Khemmanivanh" <>
"Salehi, Michael E" <>
"Martin Carpenter" <>
Ian MacPhedran <>

| Christopher L. Barnard O When I was a boy I was told that |
| / \ anybody could become president. |
| (312) 347-4901 O---O Now I'm beginning to believe it. |
| --Clarence Darrow |
+----------PGP public key available via finger or PGP keyserver---------+

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:13:31 CDT