From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25107 invoked from network); 12 Oct 2006 22:25:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.6 (2006-10-03) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.6 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Oct 2006 22:25:25 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 77014 invoked from network); 12 Oct 2006 22:25:12 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Oct 2006 22:25:12 -0000 Received: (qmail 20987 invoked by alias); 12 Oct 2006 22:25:04 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10854 Received: (qmail 20970 invoked from network); 12 Oct 2006 22:25:04 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Oct 2006 22:25:04 -0000 Received: (qmail 75759 invoked from network); 12 Oct 2006 22:25:04 -0000 Received: from vinc17.net8.nerim.net (HELO prunille.vinc17.org) (62.212.121.106) by a.mx.sunsite.dk with SMTP; 12 Oct 2006 22:25:01 -0000 Received: by prunille.vinc17.org (Postfix, from userid 501) id D77C0D562B0; Fri, 13 Oct 2006 00:24:59 +0200 (CEST) Date: Fri, 13 Oct 2006 00:24:59 +0200 From: Vincent Lefevre To: zsh-users@sunsite.dk Subject: Re: logout from interactive subshell Message-ID: <20061012222459.GJ28997@prunille.vinc17.org> Mail-Followup-To: zsh-users@sunsite.dk References: <237967ef0610120210r1d3a8c57n8850a4872b846c77@mail.gmail.com> <87ac41c0eo.fsf@asfast.com> <061012075850.ZM19537@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <061012075850.ZM19537@torch.brasslantern.com> X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.13-vl-r13495 (2006-10-09) 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)