summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-11-13 22:37:20 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-11-13 22:37:20 +0900
commitfbfdc07511283a111192e32970bee909016b47d2 (patch)
tree38c32f8ffcde50579a993e8a06163e688c1f284a /compat
parentMerge branch 'ab/pack-tests-cleanup' (diff)
parentmingw: fix isatty() after dup2() (diff)
downloadtgif-fbfdc07511283a111192e32970bee909016b47d2.tar.xz
Merge branch 'js/mingw-isatty-and-dup2'
Windows fix. * js/mingw-isatty-and-dup2: mingw: fix isatty() after dup2()
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.h3
-rw-r--r--compat/winansi.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index 4c14e30835..a577df0d74 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -406,6 +406,9 @@ int mingw_raise(int sig);
int winansi_isatty(int fd);
#define isatty winansi_isatty
+int winansi_dup2(int oldfd, int newfd);
+#define dup2 winansi_dup2
+
void winansi_init(void);
HANDLE winansi_get_osfhandle(int fd);
diff --git a/compat/winansi.c b/compat/winansi.c
index a11a0f16d2..f4f08237f9 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -474,6 +474,18 @@ static void die_lasterr(const char *fmt, ...)
va_end(params);
}
+#undef dup2
+int winansi_dup2(int oldfd, int newfd)
+{
+ int ret = dup2(oldfd, newfd);
+
+ if (!ret && newfd >= 0 && newfd <= 2)
+ fd_is_interactive[newfd] = oldfd < 0 || oldfd > 2 ?
+ 0 : fd_is_interactive[oldfd];
+
+ return ret;
+}
+
static HANDLE duplicate_handle(HANDLE hnd)
{
HANDLE hresult, hproc = GetCurrentProcess();