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.

Author aixtools@gmail.com
Recipients addaleax, aixtools@gmail.com, ericvw, gireeshpunathil
Date 2017-03-17.15:48:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1489765703.32.0.327258751254.issue29545@psf.upfronthosting.co.za>
In-reply-to
Content
Curious.

First pass: using python2.7.12 also hanged as program, on the close()

second pass: interactive - do the read first, then the close - seems to work:

root@x064:[/data/prj/python/issues/29545]cat hello.py
#!/usr/bin/env python
import errno
import os
import pty
from subprocess import Popen, STDOUT

master_fd, slave_fd = pty.openpty()
proc = Popen(['./hello'],stdout=slave_fd, close_fds=True)
os.close(slave_fd)
data = os.read(master_fd, 512)
print('got ' + repr(data))
root@x064:[/data/prj/python/issues/29545]python
Python 2.7.12 (default, Sep 29 2016, 12:02:17) [C] on aix5
Type "help", "copyright", "credits" or "license" for more information.
>>> import errno
import os
import pty
from subprocess import Popen, STDOUT
>>> >>> >>> >>>
>>> master_fd, slave_fd = pty.openpty()
>>> master_fd
3
>>> slave_fd
4
>>> proc = Popen(['./hello'],stdout=slave_fd, close_fds=True)
>>> data = os.read(master_fd, 512)
>>> datat
'hello world\r\n'
>>> os.close(slave_fd)
>>> print (got '
  File "<stdin>", line 1
    print (got '
               ^
SyntaxError: EOL while scanning string literal
>>> print('got ' + repr(data))
got 'hello world\r\n'
>>> quit()

pass 3:
swap the close() and the read() and the program works fine.

"hello.py" 11 lines, 265 characters

root@x064:[/data/prj/python/issues/29545]cat hello.py
#!/usr/bin/env python
import errno
import os
import pty
from subprocess import Popen, STDOUT

master_fd, slave_fd = pty.openpty()
proc = Popen(['./hello'],stdout=slave_fd, close_fds=True)
data = os.read(master_fd, 512)
os.close(slave_fd)
print('got ' + repr(data))

root@x064:[/data/prj/python/issues/29545]./hello.py
got 'hello world\r\n'
root@x064:[/data/prj/python/issues/29545]
History
Date User Action Args
2017-03-17 15:48:23aixtools@gmail.comsetrecipients: + aixtools@gmail.com, ericvw, gireeshpunathil, addaleax
2017-03-17 15:48:23aixtools@gmail.comsetmessageid: <1489765703.32.0.327258751254.issue29545@psf.upfronthosting.co.za>
2017-03-17 15:48:23aixtools@gmail.comlinkissue29545 messages
2017-03-17 15:48:22aixtools@gmail.comcreate