@@ -243,7 +243,6 @@ enum hide_dotfiles_type {
243
243
HIDE_DOTFILES_DOTGITONLY
244
244
};
245
245
246
- static int core_restrict_inherited_handles = -1 ;
247
246
static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
248
247
static char * unset_environment_variables ;
249
248
@@ -267,15 +266,6 @@ int mingw_core_config(const char *var, const char *value,
267
266
return 0 ;
268
267
}
269
268
270
- if (!strcmp (var , "core.restrictinheritedhandles" )) {
271
- if (value && !strcasecmp (value , "auto" ))
272
- core_restrict_inherited_handles = -1 ;
273
- else
274
- core_restrict_inherited_handles =
275
- git_config_bool (var , value );
276
- return 0 ;
277
- }
278
-
279
269
return 0 ;
280
270
}
281
271
@@ -1763,7 +1753,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1763
1753
const char * dir ,
1764
1754
int prepend_cmd , int fhin , int fhout , int fherr )
1765
1755
{
1766
- static int restrict_handle_inheritance = -1 ;
1767
1756
STARTUPINFOEXW si ;
1768
1757
PROCESS_INFORMATION pi ;
1769
1758
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL ;
@@ -1783,16 +1772,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1783
1772
/* Make sure to override previous errors, if any */
1784
1773
errno = 0 ;
1785
1774
1786
- if (restrict_handle_inheritance < 0 )
1787
- restrict_handle_inheritance = core_restrict_inherited_handles ;
1788
- /*
1789
- * The following code to restrict which handles are inherited seems
1790
- * to work properly only on Windows 7 and later, so let's disable it
1791
- * on Windows Vista and 2008.
1792
- */
1793
- if (restrict_handle_inheritance < 0 )
1794
- restrict_handle_inheritance = GetVersion () >> 16 >= 7601 ;
1795
-
1796
1775
do_unset_environment_variables ();
1797
1776
1798
1777
/* Determine whether or not we are associated to a console */
@@ -1894,7 +1873,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1894
1873
wenvblk = make_environment_block (deltaenv );
1895
1874
1896
1875
memset (& pi , 0 , sizeof (pi ));
1897
- if (restrict_handle_inheritance && stdhandles_count &&
1876
+ if (stdhandles_count &&
1898
1877
(InitializeProcThreadAttributeList (NULL , 1 , 0 , & size ) ||
1899
1878
GetLastError () == ERROR_INSUFFICIENT_BUFFER ) &&
1900
1879
(attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST )
@@ -1915,52 +1894,13 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1915
1894
& si .StartupInfo , & pi );
1916
1895
1917
1896
/*
1918
- * On Windows 2008 R2, it seems that specifying certain types of handles
1919
- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
1920
- * error. Rather than playing finicky and fragile games, let's just try
1921
- * to detect this situation and simply try again without restricting any
1922
- * handle inheritance. This is still better than failing to create
1923
- * processes.
1897
+ * On the off-chance that something with the file handle restriction
1898
+ * went wrong, silently fall back to trying without it.
1924
1899
*/
1925
- if (!ret && restrict_handle_inheritance && stdhandles_count ) {
1900
+ if (!ret && stdhandles_count ) {
1926
1901
DWORD err = GetLastError ();
1927
1902
struct strbuf buf = STRBUF_INIT ;
1928
1903
1929
- if (err != ERROR_NO_SYSTEM_RESOURCES &&
1930
- /*
1931
- * On Windows 7 and earlier, handles on pipes and character
1932
- * devices are inherited automatically, and cannot be
1933
- * specified in the thread handle list. Rather than trying
1934
- * to catch each and every corner case (and running the
1935
- * chance of *still* forgetting a few), let's just fall
1936
- * back to creating the process without trying to limit the
1937
- * handle inheritance.
1938
- */
1939
- !(err == ERROR_INVALID_PARAMETER &&
1940
- GetVersion () >> 16 < 9200 ) &&
1941
- !getenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" )) {
1942
- DWORD fl = 0 ;
1943
- int i ;
1944
-
1945
- setenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" , "1" , 1 );
1946
-
1947
- for (i = 0 ; i < stdhandles_count ; i ++ ) {
1948
- HANDLE h = stdhandles [i ];
1949
- strbuf_addf (& buf , "handle #%d: %p (type %lx, "
1950
- "handle info (%d) %lx\n" , i , h ,
1951
- GetFileType (h ),
1952
- GetHandleInformation (h , & fl ),
1953
- fl );
1954
- }
1955
- strbuf_addstr (& buf , "\nThis is a bug; please report it "
1956
- "at\nhttps://github.com/git-for-windows/"
1957
- "git/issues/new\n\n"
1958
- "To suppress this warning, please set "
1959
- "the environment variable\n\n"
1960
- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
1961
- "\n" );
1962
- }
1963
- restrict_handle_inheritance = 0 ;
1964
1904
flags &= ~EXTENDED_STARTUPINFO_PRESENT ;
1965
1905
ret = CreateProcessW (* wcmd ? wcmd : NULL , wargs , NULL , NULL ,
1966
1906
TRUE, flags , wenvblk , dir ? wdir : NULL ,
0 commit comments