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