This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: pty.spawn() leaks file descriptors
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, jamesh
Priority: normal Keywords:

Created on 2004-02-16 11:28 by jamesh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg20010 - (view) Author: James Henstridge (jamesh) Date: 2004-02-16 11:28
By running the following short program on Linux, you
can see the number of open file descriptors increase:
    import os, pty
    for i in range(10):
        print len(os.listdir('/proc/%d/fd' % os.getpid()))

This can be fixed by os.close()'ing master_fd.  This
problem seems to exist in CVS head as well as 2.3.

There are also a few changes that would be nice to see
in pty.spawn:

1) get the exit status of the child.  Could be fixed by
adding the following to the end of the function:
    pid, status = os.waitpid(pid, 0)
    return status

2) set master_fd to non-blocking mode, so that the
output is printed to the screen at the speed it is
produced by the child.
msg20011 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-06-05 16:30
Logged In: YES 

I've applied a fix to CVS HEAD; thanks for reporting this!

The two feature suggestions have been added to the RFE tracker as 
#967161 so that I can close this bug.
msg20012 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-06-05 16:31
Logged In: YES 

Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39941
2004-02-16 11:28:48jameshcreate