Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: logout from interactive subshell



On 2006-10-12 07:58:50 -0700, Bart Schaefer wrote:
> ----
> # This goes in ~/.zshrc for all interactive shells:
> trap logout USR1
> 
> if [[ ${LOGINPID:-$$} != $$ ]]
> then
>   function logout { kill -USR1 $PPID; exit }
> fi
> ----

You need to check that the parent process is an interactive zsh shell
since one can run a zsh login shell and a command in it that would
run an interactive zsh. I can see at least two cases where this can
happen:

1. With a text-mode login, then startx, then terminals with a zsh in
them.

2. With screen.

So, I suggest the following:

trap logout USR1
[[ $MYPID == $PPID ]] && logout() { kill -USR1 $PPID; exit }
export MYPID=$$

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)



Messages sorted by: Reverse Date, Date, Thread, Author