@@ -274,7 +274,6 @@ enum hide_dotfiles_type {
274
274
HIDE_DOTFILES_DOTGITONLY
275
275
};
276
276
277
- static int core_restrict_inherited_handles = -1 ;
278
277
static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY ;
279
278
static char * unset_environment_variables ;
280
279
int core_fscache ;
@@ -325,15 +324,6 @@ int mingw_core_config(const char *var, const char *value,
325
324
return 0 ;
326
325
}
327
326
328
- if (!strcmp (var , "core.restrictinheritedhandles" )) {
329
- if (value && !strcasecmp (value , "auto" ))
330
- core_restrict_inherited_handles = -1 ;
331
- else
332
- core_restrict_inherited_handles =
333
- git_config_bool (var , value );
334
- return 0 ;
335
- }
336
-
337
327
return 0 ;
338
328
}
339
329
@@ -2060,7 +2050,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
2060
2050
const char * dir , const char * prepend_cmd ,
2061
2051
int fhin , int fhout , int fherr )
2062
2052
{
2063
- static int restrict_handle_inheritance = -1 ;
2064
2053
STARTUPINFOEXW si ;
2065
2054
PROCESS_INFORMATION pi ;
2066
2055
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL ;
@@ -2080,16 +2069,6 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
2080
2069
/* Make sure to override previous errors, if any */
2081
2070
errno = 0 ;
2082
2071
2083
- if (restrict_handle_inheritance < 0 )
2084
- restrict_handle_inheritance = core_restrict_inherited_handles ;
2085
- /*
2086
- * The following code to restrict which handles are inherited seems
2087
- * to work properly only on Windows 7 and later, so let's disable it
2088
- * on Windows Vista and 2008.
2089
- */
2090
- if (restrict_handle_inheritance < 0 )
2091
- restrict_handle_inheritance = GetVersion () >> 16 >= 7601 ;
2092
-
2093
2072
do_unset_environment_variables ();
2094
2073
2095
2074
/* Determine whether or not we are associated to a console */
@@ -2195,7 +2174,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
2195
2174
wenvblk = make_environment_block (deltaenv );
2196
2175
2197
2176
memset (& pi , 0 , sizeof (pi ));
2198
- if (restrict_handle_inheritance && stdhandles_count &&
2177
+ if (stdhandles_count &&
2199
2178
(InitializeProcThreadAttributeList (NULL , 1 , 0 , & size ) ||
2200
2179
GetLastError () == ERROR_INSUFFICIENT_BUFFER ) &&
2201
2180
(attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST )
@@ -2216,52 +2195,13 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
2216
2195
& si .StartupInfo , & pi );
2217
2196
2218
2197
/*
2219
- * On Windows 2008 R2, it seems that specifying certain types of handles
2220
- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
2221
- * error. Rather than playing finicky and fragile games, let's just try
2222
- * to detect this situation and simply try again without restricting any
2223
- * handle inheritance. This is still better than failing to create
2224
- * processes.
2198
+ * On the off-chance that something with the file handle restriction
2199
+ * went wrong, silently fall back to trying without it.
2225
2200
*/
2226
- if (!ret && restrict_handle_inheritance && stdhandles_count ) {
2201
+ if (!ret && stdhandles_count ) {
2227
2202
DWORD err = GetLastError ();
2228
2203
struct strbuf buf = STRBUF_INIT ;
2229
2204
2230
- if (err != ERROR_NO_SYSTEM_RESOURCES &&
2231
- /*
2232
- * On Windows 7 and earlier, handles on pipes and character
2233
- * devices are inherited automatically, and cannot be
2234
- * specified in the thread handle list. Rather than trying
2235
- * to catch each and every corner case (and running the
2236
- * chance of *still* forgetting a few), let's just fall
2237
- * back to creating the process without trying to limit the
2238
- * handle inheritance.
2239
- */
2240
- !(err == ERROR_INVALID_PARAMETER &&
2241
- GetVersion () >> 16 < 9200 ) &&
2242
- !getenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" )) {
2243
- DWORD fl = 0 ;
2244
- int i ;
2245
-
2246
- setenv ("SUPPRESS_HANDLE_INHERITANCE_WARNING" , "1" , 1 );
2247
-
2248
- for (i = 0 ; i < stdhandles_count ; i ++ ) {
2249
- HANDLE h = stdhandles [i ];
2250
- strbuf_addf (& buf , "handle #%d: %p (type %lx, "
2251
- "handle info (%d) %lx\n" , i , h ,
2252
- GetFileType (h ),
2253
- GetHandleInformation (h , & fl ),
2254
- fl );
2255
- }
2256
- strbuf_addstr (& buf , "\nThis is a bug; please report it "
2257
- "at\nhttps://github.com/git-for-windows/"
2258
- "git/issues/new\n\n"
2259
- "To suppress this warning, please set "
2260
- "the environment variable\n\n"
2261
- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
2262
- "\n" );
2263
- }
2264
- restrict_handle_inheritance = 0 ;
2265
2205
flags &= ~EXTENDED_STARTUPINFO_PRESENT ;
2266
2206
ret = CreateProcessW (* wcmd ? wcmd : NULL , wargs , NULL , NULL ,
2267
2207
TRUE, flags , wenvblk , dir ? wdir : NULL ,
0 commit comments