Skip to content

Commit 081b5fd

Browse files
committed
mingw: tentative fix for spawning Git from TortoiseGit
This bug was reported in git-for-windows#1481 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent dc364ab commit 081b5fd

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compat/mingw.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,14 +1750,17 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
17501750
* handle inheritance. This is still better than failing to create
17511751
* processes.
17521752
*/
1753-
if (!ret && GetLastError() == ERROR_NO_SYSTEM_RESOURCES &&
1754-
restrict_handle_inheritance && stdhandles_count) {
1755-
restrict_handle_inheritance = 0;
1756-
flags &= ~EXTENDED_STARTUPINFO_PRESENT;
1757-
ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL, NULL,
1758-
stdhandles_count ? TRUE : FALSE,
1759-
flags, wenvblk, dir ? wdir : NULL,
1760-
&si.StartupInfo, &pi);
1753+
if (!ret && restrict_handle_inheritance && stdhandles_count) {
1754+
DWORD err = GetLastError();
1755+
if (err == ERROR_NO_SYSTEM_RESOURCES ||
1756+
err == ERROR_INVALID_HANDLE) {
1757+
restrict_handle_inheritance = 0;
1758+
flags &= ~EXTENDED_STARTUPINFO_PRESENT;
1759+
ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL,
1760+
NULL, TRUE, flags, wenvblk,
1761+
dir ? wdir : NULL,
1762+
&si.StartupInfo, &pi);
1763+
}
17611764
}
17621765

17631766
if (!ret)

0 commit comments

Comments
 (0)