Skip to content

Commit

Permalink
Don't set ignore status for SIGTERM and SIGINT on Linux (#3174)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed Apr 18, 2024
1 parent 8409c3c commit 096c519
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Vapor/Commands/ServeCommand.swift
Expand Up @@ -85,14 +85,18 @@ public final class ServeCommand: Command, Sendable {
// setup signal sources for shutdown
let signalQueue = DispatchQueue(label: "codes.vapor.server.shutdown")
func makeSignalSource(_ code: Int32) {
#if canImport(Darwin)
/// https://github.com/swift-server/swift-service-lifecycle/blob/main/Sources/UnixSignals/UnixSignalsSequence.swift#L77-L82
signal(code, SIG_IGN)
#endif

let source = DispatchSource.makeSignalSource(signal: code, queue: signalQueue)
source.setEventHandler {
print() // clear ^C
promise.succeed(())
}
source.resume()
box.signalSources.append(source)
signal(code, SIG_IGN)
}
makeSignalSource(SIGTERM)
makeSignalSource(SIGINT)
Expand Down

0 comments on commit 096c519

Please sign in to comment.