@@ -10,13 +10,13 @@ public struct Sigaction : Equatable, RawRepresentable {
1010 public static let defaultAction = Sigaction ( handler: . defaultHandler)
1111
1212 /**
13- Check if the given signal is ignored using `sigaction`. */
13+ Check if the given signal is ignored using `sigaction`. */
1414 public static func isSignalIgnored( _ signal: Signal ) throws -> Bool {
1515 return try Sigaction ( signal: signal) . handler == . ignoreHandler
1616 }
1717
1818 /**
19- Check if the given signal is handled with default action using `sigaction`. */
19+ Check if the given signal is handled with default action using `sigaction`. */
2020 public static func isSignalDefaultAction( _ signal: Signal ) throws -> Bool {
2121 return try Sigaction ( signal: signal) . handler == . defaultHandler
2222 }
@@ -36,32 +36,32 @@ public struct Sigaction : Equatable, RawRepresentable {
3636 }
3737
3838 /**
39- Create a `Sigaction` from a `sigaction`.
40-
41- If the handler of the sigaction is `SIG_IGN` or `SIG_DFL`, we check the
42- `sa_flags` not to contains the `SA_SIGINFO` bit. If they do, we log an error,
43- as this is invalid. */
39+ Create a `Sigaction` from a `sigaction`.
40+
41+ If the handler of the sigaction is `SIG_IGN` or `SIG_DFL`, we check the
42+ `sa_flags` not to contains the `SA_SIGINFO` bit. If they do, we log an
43+ error, as this is invalid. */
4444 public init ( rawValue: sigaction ) {
4545 self . mask = Signal . set ( from: rawValue. sa_mask)
4646 self . flags = SigactionFlags ( rawValue: rawValue. sa_flags)
4747
48- #if !os(Linux)
48+ #if !os(Linux)
4949 switch OpaquePointer ( bitPattern: unsafeBitCast ( rawValue. __sigaction_u. __sa_handler, to: Int . self) ) {
5050 case OpaquePointer ( bitPattern: unsafeBitCast ( SIG_IGN, to: Int . self) ) : self . handler = . ignoreHandler
5151 case OpaquePointer ( bitPattern: unsafeBitCast ( SIG_DFL, to: Int . self) ) : self . handler = . defaultHandler
5252 default :
5353 if flags. contains ( . siginfo) { self . handler = . posix( rawValue. __sigaction_u. __sa_sigaction) }
5454 else { self . handler = . ansiC( rawValue. __sigaction_u. __sa_handler) }
5555 }
56- #else
56+ #else
5757 switch OpaquePointer ( bitPattern: unsafeBitCast ( rawValue. __sigaction_handler. sa_handler, to: Int . self) ) {
5858 case OpaquePointer ( bitPattern: unsafeBitCast ( SIG_IGN, to: Int . self) ) : self . handler = . ignoreHandler
5959 case OpaquePointer ( bitPattern: unsafeBitCast ( SIG_DFL, to: Int . self) ) : self . handler = . defaultHandler
6060 default :
6161 if flags. contains ( . siginfo) { self . handler = . posix( rawValue. __sigaction_handler. sa_sigaction) }
6262 else { self . handler = . ansiC( rawValue. __sigaction_handler. sa_handler) }
6363 }
64- #endif
64+ #endif
6565
6666 if !isValid {
6767 SignalHandlingConfig . logger? . warning ( " Initialized an invalid Sigaction. " )
@@ -85,42 +85,42 @@ public struct Sigaction : Equatable, RawRepresentable {
8585 ret. sa_mask = Signal . sigset ( from: mask)
8686 ret. sa_flags = flags. rawValue
8787
88- #if !os(Linux)
88+ #if !os(Linux)
8989 switch handler {
9090 case . ignoreHandler: ret. __sigaction_u. __sa_handler = SIG_IGN
9191 case . defaultHandler: ret. __sigaction_u. __sa_handler = SIG_DFL
9292 case . ansiC( let h) : ret. __sigaction_u. __sa_handler = h
9393 case . posix( let h) : ret. __sigaction_u. __sa_sigaction = h
9494 }
95- #else
95+ #else
9696 switch handler {
9797 case . ignoreHandler: ret. __sigaction_handler. sa_handler = SIG_IGN
9898 case . defaultHandler: ret. __sigaction_handler. sa_handler = SIG_DFL
9999 case . ansiC( let h) : ret. __sigaction_handler. sa_handler = h
100100 case . posix( let h) : ret. __sigaction_handler. sa_sigaction = h
101101 }
102- #endif
102+ #endif
103103
104104 return ret
105105 }
106106
107107 /**
108- Only one check: do the flags **not** contain `siginfo` if handler is either
109- `.ignoreHandler` or `.defaultHandler`. */
108+ Only one check: do the flags **not** contain `siginfo` if handler is either
109+ `.ignoreHandler` or `.defaultHandler`. */
110110 public var isValid : Bool {
111111 return !flags. contains ( . siginfo) || ( handler != . ignoreHandler && handler != . defaultHandler)
112112 }
113113
114114 /**
115- Installs the sigaction and returns the old one if different.
116-
117- It is impossible for a sigaction handler to be `nil`. If the method returns
118- `nil`, the previous handler was exactly the same as the one you installed.
119- Note however the sigaction function is always called in this method.
120-
121- If `updateUnsigRegistrations` is true (default), If there are delayed
122- sigactions registered with `SigactionDelayer_Unsig`, these registrations will
123- be updated and `sigaction` will not be called. */
115+ Installs the sigaction and returns the old one if different.
116+
117+ It is impossible for a sigaction handler to be `nil`. If the method returns
118+ `nil`, the previous handler was exactly the same as the one you installed.
119+ Note however the sigaction function is always called in this method.
120+
121+ If `updateUnsigRegistrations` is true (default), If there are delayed
122+ sigactions registered with `SigactionDelayer_Unsig`, these registrations
123+ will be updated and `sigaction` will not be called. */
124124 @discardableResult
125125 public func install( on signal: Signal , revertIfIgnored: Bool = true , updateUnsigRegistrations: Bool = true ) throws -> Sigaction ? {
126126 if updateUnsigRegistrations, let oldSigaction = SigactionDelayer_Unsig . updateOriginalSigaction ( for: signal, to: self ) {
0 commit comments