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: make pty.fork() allocate a controlling tty
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: loewis, raynorj
Priority: normal Keywords: patch

Created on 2003-11-08 20:21 by raynorj, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pty_patch raynorj, 2003-11-08 20:21 patch to pty.py
Messages (4)
msg44861 - (view) Author: J Raynor (raynorj) Date: 2003-11-08 20:21
pty.fork() does not allocate a controlling tty on
systems that don't have os.forkpty().  The code for
pty.fork() tries to use os.forkpty(), and if it isn't
available, then it tries to do its work in python, but
it doesn't work.

The code does setup stdin, stdout, and stderr to use
the slave device, but it needs to do an explicit open
on the slave device to make it become a controlling tty.

This patch is against pty.py from python 2.3, but the
same change can be made to pty.py from python 2.2 and
it works there.

msg44862 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-11-10 06:38
Logged In: YES 
user_id=21627

What systems did you test this on? I remember ttyname
returning funny things on some systems.
msg44863 - (view) Author: J Raynor (raynorj) Date: 2003-11-11 01:03
Logged In: YES 
user_id=904832


This works on aix 5.2, 5.1, and 4.3.3.  It also works on
hpux 10.20.
msg44864 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-11-09 11:12
Logged In: YES 
user_id=21627

I just looked at the source of the GNU C library, and it
essentially does the same thing:
in login_tty(), it does check whether ttyname returned a
non-NULL string, and then just
opens the terminal once. It might do the null check for a
different reason; it's not
certain that the fd really is a terminal.

On systems that support TIOCSCTTY, glibc uses that instead.

So thanks for the patch; I committed it as r52686 and
r52687. There might be room for
improvement, but that can come as a separate contribution.
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39522
2003-11-08 20:21:59raynorjcreate