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

Re: timeout problem in ssh sessions

On Feb 15, 11:18pm, Andy Spiegl wrote:
} On 2008-02-15, 12:30, Bart Schaefer wrote:
} > ps="$(ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd)"
} Wonderful!  To avoid that $ps contains the ps process itself I combined
} your two suggestions:
}  ps="$(/bin/grep -v 'etime,bsdtime,cmd' =(ps -eo user,pid,ppid,s,cpu,pmem,rss,vsize,bsdstart,etime,bsdtime,cmd))" 
} Is that ok / efficient?

There's no particular problem with it but I think it's unnecessary given
the way you're filtering the output later.  The "ps" command is a child
of the subshell $(...), not of the login shell, so it will match neither
the grep for $$ nor the grep for $PPID (nor for xsel, obviously).
} > That's only telling you which descriptors are still connected to the tty,
} > not which ones are open, so you'll miss X connections and the like.
} Oh, too bad.  Actually I _do_ want to see X connections and the like
} Is there a way to achieve this?

You can load the zsh/stat module and use

for fd in {0..63}; zstat -f $fd ...

There's the additional complication that the zstat builtin is called
"stat" in most versions of zsh so you have to account for that if you
want to be portable.

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