Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Misc. zpty tweaks, plus commentary

On Nov 4, 11:29pm, I wrote:
} `zpty -w' already was able to stream into the pty (even though that's
} not documented); e.g. `zpty -w foo < file' writes the entire contents
} of the file to the pty [...] Now `zpty -r foo' can stream the output
} as well.  Unfortunately, it's still not possible to do both at once.
} The problem is that whenever zsh forks a builtin, it closes all
} descriptors numbered higher than 10, which includes the master pty
} descriptor.

Although a C-code-level fix would be preferable, a workaround has just
occurred to me:  Using a subshell will prevent the descriptors from
being closed.  So with 13116 applied, you should be able to do:

    zpty -b foo cat
    yes blah | (zpty -w foo) &
    (zpty -r foo) | less
    zpty -d foo

This reveals that still another remaining problem is that `zpty -w' on a
blocking pty doesn't stop when the process on the pty is killed.  There
doesn't seem to be any simple fix for this; write() itself is blocked,
and does not get interrupted with SIGPIPE as would normally occur.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author