Permalink
Browse files

Hopefully fix issue1434, although I'm not entirely satisfied with the…

… solution.

The whole set of conditions under which processEnded is called should
be revisited, and write pipes closing should probably not be one of them.



git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@15668 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information...
jyknight committed Jan 22, 2006
1 parent c0677ff commit 94d8f38c54e1f43668afd0589704c979ed50d432
Showing with 14 additions and 11 deletions.
  1. +14 −11 twisted/internet/process.py
@@ -92,24 +92,27 @@ class ProcessWriter(abstract.FileDescriptor):
ic = 0
enableReadHack = False
def __init__(self, reactor, proc, name, fileno):
def __init__(self, reactor, proc, name, fileno, forceReadHack=False):
"""Initialize, specifying a Process instance to connect to.
"""
abstract.FileDescriptor.__init__(self, reactor)
fdesc.setNonBlocking(fileno)
self.proc = proc
self.name = name
self.fd = fileno
# Detect if this fd is actually a write-only fd. If it's
# valid to read, don't try to detect closing via read.
# This really only means that we cannot detect a TTY's write
# pipe being closed.
try:
os.read(self.fileno(), 0)
except OSError:
# It's a write-only pipe end, enable hack
if forceReadHack:
self.enableReadHack = True
else:
# Detect if this fd is actually a write-only fd. If it's
# valid to read, don't try to detect closing via read.
# This really only means that we cannot detect a TTY's write
# pipe being closed.
try:
os.read(self.fileno(), 0)
except OSError:
# It's a write-only pipe end, enable hack
self.enableReadHack = True
if self.enableReadHack:
self.startReading()
@@ -406,7 +409,7 @@ def __init__(self, reactor, command, args, environment, path, proto,
self.pipes[childFD] = reader
if childFDs[childFD] == "w":
writer = ProcessWriter(reactor, self, childFD, parentFD)
writer = ProcessWriter(reactor, self, childFD, parentFD, forceReadHack=True)
self.pipes[childFD] = writer
try:

0 comments on commit 94d8f38

Please sign in to comment.