Skip to content

Commit f983d21

Browse files
authored
Add Musl support for the Signal utility (used to stop the preview server before exiting) (#1162)
rdar://145456460
1 parent d5fc484 commit f983d21

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/SwiftDocCUtilities/Utility/Signal.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2025 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -20,8 +20,10 @@ public struct Signal {
2020
public static func on(_ signals: [Int32], callback: @convention(c) @escaping (Int32) -> Void) {
2121
var signalAction = sigaction()
2222

23-
#if os(Linux)
24-
// This is where we get to use a triple underscore in a method name.
23+
// Different libraries name the `sigaction` fields and handler type differently.
24+
#if canImport(Musl)
25+
signalAction.__sa_handler = unsafeBitCast(callback, to: sigaction.__Unnamed_union___sa_handler.self)
26+
#elseif os(Linux)
2527
signalAction.__sigaction_handler = unsafeBitCast(callback, to: sigaction.__Unnamed_union___sigaction_handler.self)
2628
#elseif os(Android)
2729
signalAction.sa_handler = callback

0 commit comments

Comments
 (0)