From 283712d6bcb4949b7dba5c1af10f15614cb48928 Mon Sep 17 00:00:00 2001 From: Ryan Mansfield Date: Tue, 30 Sep 2025 16:04:58 -0400 Subject: [PATCH] Fix swift driver hanging on SIGINT by adding timeout forced exit When users interrupt swift driver with ctrl+c, the llbuild engine.build() call can hang indefinitely even after child processes are terminated. Add a two second timeout to force exit if graceful termination fails. Resolves https://github.com/swiftlang/swift-driver/issues/1798 --- Sources/swift-driver/main.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/swift-driver/main.swift b/Sources/swift-driver/main.swift index d34ee8115..baa6610d4 100644 --- a/Sources/swift-driver/main.swift +++ b/Sources/swift-driver/main.swift @@ -67,6 +67,11 @@ do { // to return a corresponding exit code when done. processSet.terminate() driverInterrupted = true + + // If graceful termination doesn't work within a reasonable time, force exit + DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) { + exit(1) + } } interruptSignalSource.resume()