A Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programs.
Go to file
2012-04-01 01:40:30 -07:00
agent Start the agent's child process on the libwinpty client's desktop. 2012-03-31 00:55:49 -07:00
build Replace build/.placeholder with build/.gitkeep. 2012-03-23 03:48:40 -07:00
include Realign indentation in a couple places. 2012-04-01 01:40:15 -07:00
libwinpty Realign indentation in a couple places. 2012-04-01 01:40:15 -07:00
Misc Use 4-space indentation consistently. 2012-04-01 01:40:30 -07:00
Shared Use GetEnvironmentVariable instead of getenv in DebugClient.cc. 2012-03-31 00:49:09 -07:00
unix-adapter Use 4-space indentation consistently. 2012-04-01 01:40:30 -07:00
.gitattributes Create a configure script. 2012-03-25 15:55:03 -07:00
.gitignore Update the .gitignore file. 2012-03-28 03:12:21 -07:00
config.mk Create a configure script. 2012-03-25 15:55:03 -07:00
configure Mark configure as executable and exit if uname -s isn't recognized. 2012-03-25 19:24:39 -07:00
Makefile Rename pconsole to winpty. 2012-03-25 02:29:37 -07:00
Notes.txt Stop sending trailing whitespace in Terminal::sendLine. 2012-03-28 03:10:37 -07:00
README.rst Fix an inconsistency in the README and reword a couple of sentences. 2012-04-01 01:22:04 -07:00

======
winpty
======

winpty is a Windows software package providing an interface similar to a Unix
pty-master for communicating with Windows console programs.  The package
consists of a library (libwinpty) and a tool for Cygwin and MSYS for running
Windows console programs in a Cygwin/MSYS pty.

The software works by starting the ``winpty-agent.exe`` process with a new,
hidden console window, which bridges between the console API and terminal
input/output escape codes.  It polls the hidden console's screen buffer for
changes and generates a corresponding stream of output.

The Unix adapter allows running Windows console programs (e.g. CMD, PowerShell,
IronPython, etc.) under ``mintty`` or Cygwin's ``sshd`` with
properly-functioning input (e.g. arrow and function keys) and output (e.g. line
buffering).  The library could be also useful for writing a non-Cygwin SSH
server.

Prerequisites
=============

You need the following to build winpty:

* A Cygwin or MSYS installation
* GNU make
* A MinGW 32-bit g++ toolchain, v4 or later, to build ``winpty.dll`` and
  ``winpty-agent.exe``
* A g++ toolchain targeting Cygwin or MSYS, v3 or later, to build
  ``console.exe``

MinGW appears to be split into two distributions -- MinGW (creates 32-bit
binaries) and MinGW-w64 (creates both 32-bit and 64-bit binaries).  Either
one is acceptable, but the compiler must be v4 or later and produce 32-bit
binaries.

Cygwin packages
---------------

The default g++ compiler for Cygwin targets Cygwin itself, but Cygwin also
packages MinGW compilers from both the MinGW and MinGW-w64 projects.  As of
this writing, the necessary packages are:

* Either ``mingw-gcc-g++`` or ``mingw64-i686-gcc-g++`` (but not
  ``mingw64-x86_64-gcc-g++``)
* ``gcc4-g++``

Build
=====

In the project directory, run ``./configure``, then ``make``.

This will produce three binaries:

* ``build/winpty.dll``
* ``build/winpty-agent.exe``
* ``build/console.exe``

Using the Unix adapter
======================

To run a Windows console program in ``mintty`` or Cygwin ``sshd``, prepend 
``console.exe`` to the command-line::

    $ build/console.exe c:/Python27/python.exe
    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 10 + 20
    30
    >>> exit()
    $