Friday, November 28, 2008

Why Debian is my favorite distro #17

I was struggling to get the PID of an SSH invocation that backgrounds itself (-f). It's being setup as a TCP forwarder in a script and I need to tear that down when the script finishes. Unfortunately, I couldn't find a clean way -- I ended up using a hackish "ps", but isn't there a better way? Can't ssh print its pid, like for example wget -b does?

Like that search shows, I'm not alone. This issue was reported as Debian bug #446932 in 2007. OpenSSH has it as the bug #1473 about six months later. Note that I tried the exec solution, but it did not work because ssh forks -- I hadn't read that bug report when I tried it -- but the "control socket" method seems workable.

No comments: