Commit Graph

21 Commits

Author SHA1 Message Date
Ryan Prichard
549472ec78 unix-adapter: Link statically with cyggcc_s-1.dll and cygstdc++-6.dll.
* At least for now, I'm shipping Cygwin/MSYS binaries.  On Cygwin (but
   not MSYS), the console.exe executable previously linked dynamically
   to cyggcc_s-1.dll and cygstdc++-6.dll.

   Linking dynamically with cygstdc++-6.dll seems risky for a binary
   not distributed by Cygwin, because G++'s Windows ABI is unstable, at
   least as of G++ 4.7, which turned on the __thiscall calling
   convention.  If a binary I ship ever comes into contact with a
   4.7-versioned cygstdc++-6.dll, then my binary will (very likely)
   segfault.

   So far, I've only observed this ABI incompatibility with MinGW,
   where a sufficiently upgraded MinGW configuration comes with a
   libstdc++-6.dll that is completely incompatible with every previous
   libstdc++-6.dll, so that every program built against the older
   libstdc++-6.dll segfaults immediately.  For now, Cygwin seems stuck
   at G++ 4.5, and my impression (possibly incorrect), is that G++'s
   Windows ABI was stable prior to 4.7.  I think G++'s Linux ABI is
   stable.  Presumably Cygwin will eventually update its compiler,
   though, so it makes sense to fix the problem early.

   I believe I originally chose to dynamically link the libraries
   because it was the default behavior, and I was afraid that a
   non-default option would break something.  It turns out that
   linking statically with cygstdc++-6 *does* break something -- it
   causes linker errors if the code uses std::cerr.  The workaround
   is not to use std::cerr.  This is not a problem for the
   unix-adapter, which already has to put up with MSYS' gimpy G++ 3.4
   compiler.
2012-12-20 04:07:55 -08:00
Ryan Prichard
bb42d17941 Copy the Unix environment to the Win32 environment in the unix-adapter.
This should fix issue 5.

The copying appeared to be necessary only for Cygwin, not for MSYS.  I'm
not sure why this is.  I added a call to cygwin_internal(CW_SYNC_WINENV)
for both anyway, because I didn't think it would hurt.
2012-07-29 00:35:24 +01:00
Ryan Prichard
0dccfd42e1 Fix edge cases in argvToCommandLine's argument quoting.
* Quoting is needed for empty arguments (i.e. put double-quotes in the
   command line) and for arguments containing tabs because both spaces and
   tabs can separate arguments.

 * A double-quote in the argument doesn't by itself necessitate quoting.

 * As of this change, argvToCommandLine quotes an argument in the same
   cases as Python's subprocess module.
2012-04-03 01:13:08 -07:00
Ryan Prichard
794b07e526 In the unix-adapter, convert a POSIX executable path to a Win32 path. 2012-04-01 19:15:35 -07:00
Ryan Prichard
a7bc8fcf9d Rename Shared to shared and Misc to misc. 2012-04-01 02:13:21 -07:00
Ryan Prichard
f35e5bde74 Use 4-space indentation consistently. 2012-04-01 01:40:30 -07:00
Ryan Prichard
71aa4a59bb Rename pconsole to winpty.
* This avoids a name conflict with an existing unrelated project.

 * I think winpty is a better name anyway.  (i) It's more obviously
   Windows-related.  (ii) I think it more accurately describes what it
   does.  A "pseudo-console" ought to mirror the console API and allow
   replacing the implementation built-in to Windows.  This project is only
   trying to provide functionality similar to using the master interface of
   a Unix pty, but for native console programs.
2012-03-25 02:29:37 -07:00
Ryan Prichard
e1c4763cc4 Get the UNIX adapter working with MSYS.
* Work around UNICODE deficiencies:
    - MSYS does not have wstring.
    - mbstowcs(NULL, text, 0) returns 0 on MSYS instead of returning the
      length of the converted string.
    - printf("%ls") does not work on MSYS.
2012-03-24 17:53:43 -07:00
Ryan Prichard
35754bab98 In the UNIX adapter, remove the UNIX->Win32 environment conversion.
It doesn't work because it leaves in the Cygwin-style paths in variables
like PATH and TMP.

(Also, it doesn't build with MSYS because MSYS's old G++ toolchain lacks
std::wstring.)
2012-03-24 17:23:18 -07:00
Ryan Prichard
9ed1b5b286 Print usage in the UNIX adapter. 2012-03-24 17:20:08 -07:00
Ryan Prichard
5010f5e1a6 Print an error message when CreateProcess fails.
I suspect that the library API (pconsole_open) should not be calling exit
if it can't start the agent process, but I don't want to deal with that
right now.
2012-03-24 17:19:55 -07:00
Ryan Prichard
5c185c1617 In the UNIX adapter, start the child process specified on the command line.
* Also propagate the UNIX environment to Win32.  This code doesn't really
   work because variables like PATH need path-translation, but I'd like to
   save a record of it before killing it off.
2012-03-24 16:48:41 -07:00
Ryan Prichard
44554d5e9d Add an MIT copyright notice to all the source files. 2012-03-23 03:11:34 -07:00
Ryan Prichard
7e6f8195ba Turn on -Wall and fix build warnings. No bug fixes. 2012-03-21 00:14:04 -07:00
Ryan Prichard
0afc69c733 Move the three output binaries into a build directory. 2012-03-21 00:13:46 -07:00
Ryan Prichard
1901ed62d6 Add some TODO comments. 2012-02-20 04:54:18 -08:00
Ryan Prichard
e7c5342479 Make the unix-adapter work on MSYS.
- In my MSYS environment, gcc/g++ are the MinGW compilers that target
   Win32.  We really need compilers that target the MSYS environment.
   Add a config-unix.mk for building the unix-adapter.

 - My MSYS environment lacks a pipe2 function, but I can get the same
   effect using pipe and fcntl, so do that instead.
2012-02-20 03:34:14 -08:00
Ryan Prichard
00a6c3b90e Shut down the unix-adapter when the child process exits.
- In the agent, poll for the process exit at the same time we pull for
   output.  Once the child exits, record the exit code and close the data
   pipe.

 - In the unix-adapter, shut the program down once the input or output
   handlers abort.  Before exiting, query the agent for the exit code.

 - Also: in the unix-adapter, apparently receiving the SIGWINCH signal can
   interrupt both select and the InputHandler's read system call.  I hope
   it doesn't affect the blocking Win32 APIs, but I'm not really sure.
2012-02-20 03:30:43 -08:00
Ryan Prichard
90164c34a9 Get the agent + libpconsole + unix-adapter trio working.
- Update the Agent to use separate control and data pipes and to receive
   arbitrary-sized packets.  Handle child process creation in the agent.

 - Fix bugs in libpconsole:
    - Insert a space between the pipe names on the agent command line.
    - Don't close the desktop and window station until after connecting
      to the agent's pipes.

 - Change the format of the pconsole_start_process env parameter from an
   array of wide-character-string pointers to a single contiguous block of
   memory, like that accepted by CreateProcess.
2012-02-20 01:23:46 -08:00
Ryan Prichard
27f0c4d156 Get pconsole.exe and pconsole.dll building simultaneously.
* Remove obsolete comments and APIs.

 * In pconsole.exe, use two threads to handle pconsole<->pty communication.
   I use blocking I/O for the pty.  For the Win32 pipe to the pconsole
   agent, I use overlapped I/O and emulate blocking I/O.

   I'm not sure I *have* to open the pipe in overlapped mode.  When I last
   tried using non-overlapped I/O, I had a problem where a pending read
   would block writes (or vice versa).  Maybe setting the overlapped
   parameter to {Read,Write}File would be sufficient.
2012-02-16 03:49:17 -08:00
Ryan Prichard
19d9c1832c Add a Unix pty<->pconsole adapter. 2012-01-28 14:23:31 -08:00