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.

classification
Title: pty.fork() leaves slave fd's open on Solaris
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: dmeranda, georg.brandl, k5r2a, slowrey
Priority: normal Keywords:

Created on 2004-04-12 14:21 by slowrey, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg20481 - (view) Author: Scott Lowrey (slowrey) Date: 2004-04-12 14:21
On a Solaris 2.8 system, slave file descriptors are
left open after the child process is gone and the
master has been closed.

The pty.fork() function attempts to use os.forkpty()
first.  When that fails (apparently the os module does
not provide forkpty() on Solaris?), it uses openpty()
and os.fork().  openpty() returns master and slave file
descriptors.  Since pty.fork() only returns the
master_fd, it is not clear to me how the slave would
ever be closed since the caller doesn't have access to
it.  Perhaps pty.fork is supposed to take care of this?

I am using pexpect to control my pty's, so I don't have
much expertise in this area other than what I've
gleaned from the code.
At any rate, on a long running process used to test
other programs, the open file descriptors pile up until
the ulimit is reached.  I've worked around this by
modifying pexpect.close() to use os.close(self.child_fd
+ 1).  A hack, I'm sure... :)
msg20482 - (view) Author: HyunKook Kim (k5r2a) Date: 2004-08-27 08:07
Logged In: YES 
user_id=604333

Thank you very much for your comments 

My Case is same to yours.
 -platform : Solaris 5.8
 -Python : 2.3.3
 -pyexpect: 0.99
msg20483 - (view) Author: Deron Meranda (dmeranda) Date: 2007-01-31 21:00
I am seeing the exact same problem under HP-UX 11.0
(python 2.5).  Slave descriptors are leaked.

This is a problem with Python's pty.fork(), not
with pexpect.
msg20484 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-01-31 22:53
This is already fixed in Subversion, see patch #783050.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40142
2004-04-12 14:21:37slowreycreate