@@ -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
@@ -1760,7 +1750,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1760
1750
const char * dir ,
1761
1751
int prepend_cmd , int fhin , int fhout , int fherr )
1762
1752
{
1763
- static int restrict_handle_inheritance = -1 ;
1764
1753
STARTUPINFOEXW si ;
1765
1754
PROCESS_INFORMATION pi ;
1766
1755
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL ;
@@ -1780,16 +1769,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1780
1769
/* Make sure to override previous errors, if any */
1781
1770
errno = 0 ;
1782
1771
1783
- if (restrict_handle_inheritance < 0 )
1784
- restrict_handle_inheritance = core_restrict_inherited_handles ;
1785
- /*
1786
- * The following code to restrict which handles are inherited seems
1787
- * to work properly only on Windows 7 and later, so let's disable it
1788
- * on Windows Vista and 2008.
1789
- */
1790
- if (restrict_handle_inheritance < 0 )
1791
- restrict_handle_inheritance = GetVersion () >> 16 >= 7601 ;
1792
-
1793
1772
do_unset_environment_variables ();
1794
1773
1795
1774
/* Determine whether or not we are associated to a console */
@@ -1891,7 +1870,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1891
1870
wenvblk = make_environment_block (deltaenv );
1892
1871
1893
1872
memset (& pi , 0 , sizeof (pi ));
1894
- if (restrict_handle_inheritance && stdhandles_count &&
1873
+ if (stdhandles_count &&
1895
1874
(InitializeProcThreadAttributeList (NULL , 1 , 0 , & size ) ||
1896
1875
GetLastError () == ERROR_INSUFFICIENT_BUFFER ) &&
1897
1876
(attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST )
@@ -1912,52 +1891,13 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
1912
1891
& si .StartupInfo , & pi );
1913
1892
1914
1893
/*
1915
- * On Windows 2008 R2, it seems that specifying certain types of handles
1916
- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
1917
- * error. Rather than playing finicky and fragile games, let's just try
1918
- * to detect this situation and simply try again without restricting any
1919
- * handle inheritance. This is still better than failing to create
1920
- * processes.
1894
+ * On the off-chance that something with the file handle restriction
1895
+ * went wrong, silently fall back to trying without it.
1921
1896
*/
1922
- if (!ret && restrict_handle_inheritance && stdhandles_count ) {
1897
+ if (!ret && stdhandles_count ) {
1923
1898
DWORD err = GetLastError ();
1924
1899
struct strbuf buf = STRBUF_INIT ;
1925
1900
1926
- if (err != ERROR_NO_SYSTEM_RESOURCES &&
1927
- /*
1928
- * On Windows 7 and earlier, handles on pipes and character
1929
- * devices are inherited automatically, and cannot be
1930
- * specified in the thread handle list. Rather than trying
1931
- * to catch each and every corner case (and running the
1932
- * chance of *still* forgetting a few), let's just fall
1933
- * back to creating the process without trying to limit the
1934
- * handle inheritance.
1935
- */
1936
- !(err == ERROR_INVALID_PARAMETER &&
1937
- GetVersion () >> 16 < 9200 ) &&
1938
- !getenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" )) {
1939
- DWORD fl = 0 ;
1940
- int i ;
1941
-
1942
- setenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" , "1" , 1 );
1943
-
1944
- for (i = 0 ; i < stdhandles_count ; i ++ ) {
1945
- HANDLE h = stdhandles [i ];
1946
- strbuf_addf (& buf , "handle #%d: %p (type %lx, "
1947
- "handle info (%d) %lx\n" , i , h ,
1948
- GetFileType (h ),
1949
- GetHandleInformation (h , & fl ),
1950
- fl );
1951
- }
1952
- strbuf_addstr (& buf , "\nThis is a bug; please report it "
1953
- "at\nhttps://github.com/git-for-windows/"
1954
- "git/issues/new\n\n"
1955
- "To suppress this warning, please set "
1956
- "the environment variable\n\n"
1957
- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
1958
- "\n" );
1959
- }
1960
- restrict_handle_inheritance = 0 ;
1961
1901
flags &= ~EXTENDED_STARTUPINFO_PRESENT ;
1962
1902
ret = CreateProcessW (* wcmd ? wcmd : NULL , wargs , NULL , NULL ,
1963
1903
TRUE, flags , wenvblk , dir ? wdir : NULL ,
0 commit comments