bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: logout from interactive subshell


From: Vincent Lefevre
Subject: Re: logout from interactive subshell
Date: Thu, 12 Oct 2006 12:04:36 +0200
User-agent: Mutt/1.5.13-vl-r13495 (2006-10-09)

On 2006-10-12 10:47:38 +0200, Com MN PG P E B Consultant 3 wrote:
> Does someone know how to deal with the following situation?
> 
> Very often I do the following pattern:
> 
>    (1) rlogin to a foreign host
>    (2) Invoke a subshell (for example because I'm setting a Clearcase
> View)

Is it a subshell or a second-level shell? (In the first case, $$ and
$PPID remain the same.)

>    (3) Logout from the host
> 
> Step (3) needs two steps: First I have to type 'exit' to leave the
> subshell, and then either 'exit' or 'logout' to leave the login
> shell.
> 
> Is it possible to automate this in such a way that I have to type
> only one command, to leave all subshells (in this case, only 1, but
> in general, I might be several subshells deep) AND then logout?
> 
> One idea would be to use ps, locate the process to the current
> subshell, crawling upwards via the PPIDs to find the PID of the
> login shell, and kill it. But this seems to be such an awkward
> solution, that I thought maybe there is an easier way to do it.

You don't need ps. Just get the ppid with $PPID if possible (see
above) or by some other mean (see thread "Subshells and parameters"
in the zsh-users archives). Each subshell can use a trap to be able
to kill its parent. But bash and zsh behave differently concerning
traps.

Alternatively, the command that invokes the subshell could call
'exit' after it has finished (you can write a wrapper, e.g. as a
shell function).

-- 
Vincent Lefèvre <vincent@vinc17.org> - 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)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]