@@ -246,7 +246,6 @@ enum hide_dotfiles_type {
246
246
HIDE_DOTFILES_DOTGITONLY
247
247
};
248
248
249
- static int core_restrict_inherited_handles = -1 ;
250
249
static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
251
250
static char * unset_environment_variables ;
252
251
@@ -270,15 +269,6 @@ int mingw_core_config(const char *var, const char *value,
270
269
return 0 ;
271
270
}
272
271
273
- if (!strcmp (var , "core.restrictinheritedhandles" )) {
274
- if (value && !strcasecmp (value , "auto" ))
275
- core_restrict_inherited_handles = -1 ;
276
- else
277
- core_restrict_inherited_handles =
278
- git_config_bool (var , value );
279
- return 0 ;
280
- }
281
-
282
272
return 0 ;
283
273
}
284
274
@@ -1783,7 +1773,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1783
1773
const char * dir ,
1784
1774
int prepend_cmd , int fhin , int fhout , int fherr )
1785
1775
{
1786
- static int restrict_handle_inheritance = -1 ;
1787
1776
STARTUPINFOEXW si ;
1788
1777
PROCESS_INFORMATION pi ;
1789
1778
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL ;
@@ -1803,16 +1792,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1803
1792
/* Make sure to override previous errors, if any */
1804
1793
errno = 0 ;
1805
1794
1806
- if (restrict_handle_inheritance < 0 )
1807
- restrict_handle_inheritance = core_restrict_inherited_handles ;
1808
- /*
1809
- * The following code to restrict which handles are inherited seems
1810
- * to work properly only on Windows 7 and later, so let's disable it
1811
- * on Windows Vista and 2008.
1812
- */
1813
- if (restrict_handle_inheritance < 0 )
1814
- restrict_handle_inheritance = GetVersion () >> 16 >= 7601 ;
1815
-
1816
1795
do_unset_environment_variables ();
1817
1796
1818
1797
/* Determine whether or not we are associated to a console */
@@ -1914,7 +1893,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1914
1893
wenvblk = make_environment_block (deltaenv );
1915
1894
1916
1895
memset (& pi , 0 , sizeof (pi ));
1917
- if (restrict_handle_inheritance && stdhandles_count &&
1896
+ if (stdhandles_count &&
1918
1897
(InitializeProcThreadAttributeList (NULL , 1 , 0 , & size ) ||
1919
1898
GetLastError () == ERROR_INSUFFICIENT_BUFFER ) &&
1920
1899
(attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST )
@@ -1935,52 +1914,13 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1935
1914
& si .StartupInfo , & pi );
1936
1915
1937
1916
/*
1938
- * On Windows 2008 R2, it seems that specifying certain types of handles
1939
- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
1940
- * error. Rather than playing finicky and fragile games, let's just try
1941
- * to detect this situation and simply try again without restricting any
1942
- * handle inheritance. This is still better than failing to create
1943
- * processes.
1917
+ * On the off-chance that something with the file handle restriction
1918
+ * went wrong, silently fall back to trying without it.
1944
1919
*/
1945
- if (!ret && restrict_handle_inheritance && stdhandles_count ) {
1920
+ if (!ret && stdhandles_count ) {
1946
1921
DWORD err = GetLastError ();
1947
1922
struct strbuf buf = STRBUF_INIT ;
1948
1923
1949
- if (err != ERROR_NO_SYSTEM_RESOURCES &&
1950
- /*
1951
- * On Windows 7 and earlier, handles on pipes and character
1952
- * devices are inherited automatically, and cannot be
1953
- * specified in the thread handle list. Rather than trying
1954
- * to catch each and every corner case (and running the
1955
- * chance of *still* forgetting a few), let's just fall
1956
- * back to creating the process without trying to limit the
1957
- * handle inheritance.
1958
- */
1959
- !(err == ERROR_INVALID_PARAMETER &&
1960
- GetVersion () >> 16 < 9200 ) &&
1961
- !getenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" )) {
1962
- DWORD fl = 0 ;
1963
- int i ;
1964
-
1965
- setenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" , "1" , 1 );
1966
-
1967
- for (i = 0 ; i < stdhandles_count ; i ++ ) {
1968
- HANDLE h = stdhandles [i ];
1969
- strbuf_addf (& buf , "handle #%d: %p (type %lx, "
1970
- "handle info (%d) %lx\n" , i , h ,
1971
- GetFileType (h ),
1972
- GetHandleInformation (h , & fl ),
1973
- fl );
1974
- }
1975
- strbuf_addstr (& buf , "\nThis is a bug; please report it "
1976
- "at\nhttps://github.com/git-for-windows/"
1977
- "git/issues/new\n\n"
1978
- "To suppress this warning, please set "
1979
- "the environment variable\n\n"
1980
- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
1981
- "\n" );
1982
- }
1983
- restrict_handle_inheritance = 0 ;
1984
1924
flags &= ~EXTENDED_STARTUPINFO_PRESENT ;
1985
1925
ret = CreateProcessW (* wcmd ? wcmd : NULL , wargs , NULL , NULL ,
1986
1926
TRUE, flags , wenvblk , dir ? wdir : NULL ,
0 commit comments