Forwarding unwritable FD hangs

Normally, redirecting stdout to an unwritable FD prints an error:

$ /bin/echo hello 1</dev/null
/bin/echo: write error: Bad file descriptor

Although the shell's builtin "echo" command does not print the error:

$ echo hello 1</dev/null

Forwarding this FD using pola-run results in a traceback being printed on PlashRelease1.18 and pola-run then hangs:

$ pola-run -fw / -e echo hello 1</dev/null
Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/plash/filedesc.py", line 95, in _write_callback
    written_count = os.write(self._dest_fd, self._buf)
OSError: [Errno 9] Bad file descriptor
Traceback (most recent call last):
  File "/var/lib/python-support/python2.4/plash/pola_run_args.py", line 310, in callback
    forwarder.flush()
  File "/var/lib/python-support/python2.4/plash/filedesc.py", line 118, in flush
    written = os.write(self._dest_fd, self._buf)
OSError: [Errno 9] Bad file descriptor
<hangs...>

SSH handles this correctly:

$ ssh localhost echo hello 1</dev/null

In later versions, with PlashIssues/StdoutGetsTruncated fixed, the traceback is not printed but pola-run still hangs. The cause is that poll() never returns POLLIN or POLLOUT for unreadable and unwritable FDs respectively.

This was found by Thomas Leonard: see http://lists.gnu.org/archive/html/plash/2007-12/msg00000.html

See EventLoopAndFDs for general implementation notes in this area.

PlashIssues/ForwardingUnwritableFDHangs (last edited 2008-03-30 17:26:55 by MarkSeaborn)