Message170153
| Author |
amoffat |
| Recipients |
amoffat, ned.deily |
| Date |
2012年09月10日.02:42:19 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1347244940.67.0.761365045318.issue15898@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
If I move tcsetattr into the parent, the race condition still exists. If I move it into the child, before the write(), it works.
My environment is OSX 10.7.2 inside of Virtualbox (maybe this is the problem?)
I've shuffled some code around, and found case that fails consistently in python 3, but succeeds consistently on python 2.7. It doesn't use tcsetattr at all, which is making me realize the problem may be deeper than I originally thought. Are you able to confirm this, Ned?
import os
import pty
import resource
import signal
import tty
import time
master, slave = pty.openpty()
pid = os.fork()
# child process
if pid == 0:
os.setsid()
os.close(master)
os.dup2(slave, 0)
os.dup2(slave, 1)
os.dup2(slave, 2)
max_fd = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
os.closerange(3, max_fd)
# make controlling terminal. taken from pty.fork
tmp_fd = os.open(os.ttyname(1), os.O_RDWR)
os.close(tmp_fd)
os.write(1, "testing".encode())
os._exit(255)
# parent process
else:
time.sleep(0.5)
os.close(slave)
try:
print(os.read(master, 1024))
finally:
os.kill(pid, signal.SIGKILL) |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年09月10日 02:42:20 | amoffat | set | recipients:
+ amoffat, ned.deily |
| 2012年09月10日 02:42:20 | amoffat | set | messageid: <1347244940.67.0.761365045318.issue15898@psf.upfronthosting.co.za> |
| 2012年09月10日 02:42:20 | amoffat | link | issue15898 messages |
| 2012年09月10日 02:42:19 | amoffat | create |
|