Merge branch 'fixup-handle-inheritance-warning'

Yet another fix to the file handle inheritance restricting patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2018-03-07 15:31:36 +01:00

View File

@@ -1752,6 +1752,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
*/
if (!ret && restrict_handle_inheritance && stdhandles_count) {
DWORD err = GetLastError();
struct strbuf buf = STRBUF_INIT;
if (err != ERROR_NO_SYSTEM_RESOURCES &&
/*
* On Windows 7 and earlier, handles on pipes and character
@@ -1765,7 +1767,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
!(err == ERROR_INVALID_PARAMETER &&
GetVersion() >> 16 < 9200) &&
!getenv("SUPPRESS_HANDLE_INHERITANCE_WARNING")) {
struct strbuf buf = STRBUF_INIT;
DWORD fl;
int i;
@@ -1786,15 +1787,16 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
"the environment variable\n\n"
"\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
"\n");
warning("failed to restrict file handles (%ld)\n\n%s",
err, buf.buf);
strbuf_release(&buf);
}
restrict_handle_inheritance = 0;
flags &= ~EXTENDED_STARTUPINFO_PRESENT;
ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL, NULL,
TRUE, flags, wenvblk, dir ? wdir : NULL,
&si.StartupInfo, &pi);
if (ret)
warning("failed to restrict file handles (%ld)\n\n%s",
err, buf.buf);
strbuf_release(&buf);
}
if (!ret)