The command kill $$
should kill current bash, but it seems that it doesn't work:
$ ps -p $$
PID TTY TIME CMD
18179 pts/4 00:00:00 bash
$ kill $$
$ ps -p $$
PID TTY TIME CMD
18179 pts/4 00:00:00 bash
Why?
I'm not sure why one would like to kill
the current shell. Nevertheless...
kill PID
would send SIGTERM
when no signal is specified. bash
ignores SIGTERM
and SIGQUIT
in the absence of any traps.
You'll achieve the desired effect if you were to say
kill -9 $$
or
kill -SIGKILL $$
Quoting from the manual:
When Bash is interactive, in the absence of any traps, it ignores
SIGTERM
(so that ‘kill 0
’ does not kill an interactive shell), andSIGINT
is caught and handled (so that the wait builtin is interruptible). When Bash receives aSIGINT
, it breaks out of any executing loops. In all cases, Bash ignoresSIGQUIT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With