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

Re: timeout problem in ssh sessions



On 2008-02-15 11:32:20 +0100, Andy Spiegl wrote:
> 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

I think it would probably be better to kill the parent sshd, as if you
have two ssh sessions to the same machine, terminating the first one
will also terminate xsel for the other one.

-- 
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