Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: timeout problem in ssh sessions
- X-seq: zsh-users 12578
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: ZSH User List <zsh-users@xxxxxxxxxx>
- Subject: Re: timeout problem in ssh sessions
- Date: Fri, 15 Feb 2008 11:32:20 +0100
- In-reply-to: <chaz20080214174259.GA7729@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <20080214181836.GP619@xxxxxxxxxxxxxxxxxxx> <20080214180818.GO619@xxxxxxxxxxxxxxxxxxx>
- Kreccount: 1
- Mail-followup-to: ZSH User List <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20080211233404.GA13398@xxxxxxxxx> <080212083755.ZM20121@xxxxxxxxxxxxxxxxxxxxxx> <20080212232947.GA13793@xxxxxxxxx> <080212200708.ZM20711@xxxxxxxxxxxxxxxxxxxxxx> <20080213134200.GB31852@xxxxxxxxx> <200802131349.m1DDnXRF004831@xxxxxxxxxxxxxx> <27b8b8a0802130621x47568c7fo304848d02a1c6e76@xxxxxxxxxxxxxx> <20080213143803.GI619@xxxxxxxxxxxxxxxxxxx> <20080214125415.GC31852@xxxxxxxxx> <20080214180818.GO619@xxxxxxxxxxxxxxxxxxx>
Thanks to Vincent and Stephane I came up with the following .zlogout now
which solves all my problems _and_ is interesting to read:
---------------------.-----------------.------------.-----------------
echo "Terminating shell (PID $$) on TTY `tty|cut -dy -f2`:"
ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd | /bin/grep -v "etime,bsdtime,cmd" | /bin/grep -iE "(^USER|$$)" | /bin/grep -v "grep -iE"
echo ""
echo Parent process (PPID $PPID):
ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd | /bin/grep -v "etime,bsdtime,cmd" | /bin/grep -iE "(^USER|$PPID)" | /bin/grep -v "grep -iE"
echo ""
echo -n "Still open file descriptors: "
perl -e 'print join(" ", grep { -t $_ } 0..63)."\n"'
echo ""
if whence xsel > /dev/null 2>&1; then
LEFTOVER=`ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd | /bin/grep -v "etime,bsdtime,cmd" | /bin/grep -iE xsel | /bin/grep -v "grep -iE"`
if [[ -n $LEFTOVER ]]; then
echo 'Leftover "xsel" process:'
echo $LEFTOVER
# kill xsel (started by .zsh/functions/mouse.support) if in a ssh session
# otherwise sshd will hang until the X clipboard is read or cleared
if [[ -z ${OSTYPE:#linux*} && -n $SSH_CLIENT &&
${(M)${(f)"$(</proc/$PPID/status)"}:#Name:*} == Name:[[:blank:]]sshd ]]; then
echo -n "Terminating xsel..."
xsel -c -b
echo -e "done.\n"
# or kill the parent sshd (pretty brutal, might close other programs!)
# kill -HUP $PPID 2>/dev/null
fi
fi
fi
echo 'Last user was: '`whoami`'. Bye!'
---------------------.-----------------.------------.-----------------
Thanks guys!
Andy.
--
As far as we know our computer has never had an undetected error.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author