I recently noticed a LOT of ssh-agent processes running on my system (CentOS 4.2). It seems that the ssh-agent gets started before the session manager (in /etc/X11/xinit/xinitrc-common) which is great. The only problem is that the agent process does not die when the session shuts down.
I run ssh-add in my session startup to get my key loaded into ssh-agent, so that might be part of the issue. I just haven't been able to figure out where to kill the beast. Is there somewhere I can run an arbitrary program when the session manager runs down? A medium-intensity search of the docs and sourcecode didn't turn up anything applicable. Plenty of ways to run programs at session START, but not at the end. Anybody got any ideas?