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