Skip to content

Commit

Permalink
mingw: try to figure out where TortoiseGit's (HANDLE)-2 comes from
Browse files Browse the repository at this point in the history
It was reported that TortoiseGit passes in an stdin (HANDLE)-2 in
git-for-windows#1481 (comment).
Let's figure out where that comes from.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 7, 2018
1 parent 9ca726a commit 0922cb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compat/mingw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
memset(&si, 0, sizeof(si));
si.StartupInfo.cb = sizeof(si);
si.StartupInfo.hStdInput = winansi_get_osfhandle(fhin);
if (debug_1481)
warning("fhin: %d, hstdInput: %p",
fhin, si.StartupInfo.hStdInput);
si.StartupInfo.hStdOutput = winansi_get_osfhandle(fhout);
si.StartupInfo.hStdError = winansi_get_osfhandle(fherr);

Expand Down
7 changes: 7 additions & 0 deletions compat/winansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "win32.h"
#include "win32/lazyload.h"

extern int debug_1481;

static int fd_is_interactive[3] = { 0, 0, 0 };
#define FD_CONSOLE 0x1
#define FD_SWAPPED 0x2
Expand Down Expand Up @@ -660,6 +662,11 @@ void winansi_init(void)
*/
HANDLE winansi_get_osfhandle(int fd)
{
if (debug_1481)
warning("get_osf_handle for %d (fd_is_interactive %x %x): "
"%p (%p %p)",
fd, fd_is_interactive[1], fd_is_interactive[2],
(void *)_get_osfhandle(fd), hconsole1, hconsole2);
if (fd == 1 && (fd_is_interactive[1] & FD_SWAPPED))
return hconsole1;
if (fd == 2 && (fd_is_interactive[2] & FD_SWAPPED))
Expand Down

0 comments on commit 0922cb3

Please sign in to comment.