@@ -271,17 +271,6 @@ BacktraceInitializer::BacktraceInitializer() {
271
271
if (backtracing)
272
272
_swift_parseBacktracingSettings (backtracing);
273
273
274
- #if TARGET_OS_OSX || TARGET_OS_MACCATALYST
275
- // Make sure that all fds are closed except for stdin/stdout/stderr.
276
- posix_spawnattr_init (&backtraceSpawnAttrs);
277
- posix_spawnattr_setflags (&backtraceSpawnAttrs, POSIX_SPAWN_CLOEXEC_DEFAULT);
278
-
279
- posix_spawn_file_actions_init (&backtraceFileActions);
280
- posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDIN_FILENO);
281
- posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDOUT_FILENO);
282
- posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDERR_FILENO);
283
- #endif
284
-
285
274
#if !SWIFT_BACKTRACE_ON_CRASH_SUPPORTED
286
275
if (_swift_backtraceSettings.enabled != OnOffTty::Off) {
287
276
swift::warning (0 ,
@@ -439,6 +428,17 @@ BacktraceInitializer::BacktraceInitializer() {
439
428
}
440
429
441
430
if (_swift_backtraceSettings.enabled == OnOffTty::On) {
431
+ #if TARGET_OS_OSX || TARGET_OS_MACCATALYST
432
+ // Make sure that all fds are closed except for stdin/stdout/stderr.
433
+ posix_spawnattr_init (&backtraceSpawnAttrs);
434
+ posix_spawnattr_setflags (&backtraceSpawnAttrs, POSIX_SPAWN_CLOEXEC_DEFAULT);
435
+
436
+ posix_spawn_file_actions_init (&backtraceFileActions);
437
+ posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDIN_FILENO);
438
+ posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDOUT_FILENO);
439
+ posix_spawn_file_actions_addinherit_np (&backtraceFileActions, STDERR_FILENO);
440
+ #endif
441
+
442
442
ErrorCode err = _swift_installCrashHandler ();
443
443
if (err != 0 ) {
444
444
swift::warning (0 ,
0 commit comments