For each SSH session one file descriptor is leaked:
# python
Python 2.2.3 (#1, Jun 12 2003, 09:31:58)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyssh
>>> s=pyssh.Ssh()
--- switching to terminal 2
# ps -ef | grep python
root 12737 12730 0 10:59 pts/2 00:00:08 python /usr/lib/python2.2/site-packages/mpcsim/main.py
root 13592 13078 0 17:21 pts/6 00:00:00 python
root 13595 13137 0 17:21 pts/7 00:00:00 grep python
# lsof -p 13592 | grep ptmx | wc -l
0
--- switching back to terminal 1
>>> for i in range(10):
... s.login()
... s.logout()
...
User input required for ssh connection.
(login/logout spam)
>>>
--- switching back to terminal 2
# lsof -p 13592 | grep ptmx | wc -l
10
Following patch fixes this:
--- ptyext.orig.py 2007-08-02 17:27:13.000000000 +0200
+++ ptyext.py 2007-08-02 17:27:53.000000000 +0200
@@ -161,6 +161,8 @@
os.close(stdin_fd)
if stdout_fd > STDERR_FILENO:
os.close(stdout_fd)
+ if master_fd > STDERR_FILENO:
+ os.close(master_fd)
def spawn(argv, master_read=_read, stdin_read=_read, stdin_fd=STDIN_FILENO,
stdout_fd=STDOUT_FILENO):