Thomas Wolff
2018-04-04 17:07:38 UTC
The interworking problems of pty-based terminals with native Windows
programs have long been discussed and raise recurring user reports and
complaints. Mintty issues https://github.com/mintty/mintty/issues/56
(Improve support for native console programs) and
https://github.com/mintty/mintty/issues/376 (Use different encodings for
native Windows commands output and remote output) have dozens of duplicates.
There is the fairly well-known wrapper winpty which solves most of the
interworking problems. However, it needs to be involved explicitly and
selectively for Windows command-line applications.
So I had the idea that cygwin could apply winpty wrapping automatically
when it detects that a non-cygwin command-line program is being called.
The attached patch demonstrates how this would work. It is a
proof-of-concept, not ready for integration but provided for discussion
of the approach (thus not sent to cygwin-patches).
If it is appreciated, there are a number of open issues:
* The patch offers two methods. The activated one (#ifdef
inject_winpty_recursively) works but leaves a memory leak in the argv1
array needed to expand the argv with the injected wrapper. The other
one, which tries to inject winpty into argv and then continue the
function linearly, would solve the memory leak but does not work (yet)...
* The winpty tool is not even a cygwin package yet. If the injection
approach is approved, it should be packaged as a base package, or even
its code could be migrated into cygwin.
* As some people may object such a magic (and it might in fact raise
unexpected problems), it could also be made dependent on a setting in
the CYGWIN environment variable.
Looking forward to feedback
Thomas
programs have long been discussed and raise recurring user reports and
complaints. Mintty issues https://github.com/mintty/mintty/issues/56
(Improve support for native console programs) and
https://github.com/mintty/mintty/issues/376 (Use different encodings for
native Windows commands output and remote output) have dozens of duplicates.
There is the fairly well-known wrapper winpty which solves most of the
interworking problems. However, it needs to be involved explicitly and
selectively for Windows command-line applications.
So I had the idea that cygwin could apply winpty wrapping automatically
when it detects that a non-cygwin command-line program is being called.
The attached patch demonstrates how this would work. It is a
proof-of-concept, not ready for integration but provided for discussion
of the approach (thus not sent to cygwin-patches).
If it is appreciated, there are a number of open issues:
* The patch offers two methods. The activated one (#ifdef
inject_winpty_recursively) works but leaves a memory leak in the argv1
array needed to expand the argv with the injected wrapper. The other
one, which tries to inject winpty into argv and then continue the
function linearly, would solve the memory leak but does not work (yet)...
* The winpty tool is not even a cygwin package yet. If the injection
approach is approved, it should be packaged as a base package, or even
its code could be migrated into cygwin.
* As some people may object such a magic (and it might in fact raise
unexpected problems), it could also be made dependent on a setting in
the CYGWIN environment variable.
Looking forward to feedback
Thomas