mirror of
https://github.com/apple/swift-system
synced 2026-11-24 04:38:14 +00:00
Signal definitions
This commit is contained in:
1 parent
55d9da0dcd
commit
ffc90f58de
4 files changed
+447
No files matched your search
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2021 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
import Darwin
|
||||
#endif
|
||||
|
||||
extension CInterop {
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
/// The C `int` type
|
||||
public typealias Signal = CInt
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
Copyright (c) 2021 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
import Darwin
|
||||
#endif
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
/// hangup
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGHUP: CInterop.Signal { SIGHUP }
|
||||
/// interrupt
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGINT: CInterop.Signal { SIGINT }
|
||||
/// quit
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGQUIT: CInterop.Signal { SIGQUIT }
|
||||
/// illegal instruction (not reset when caught)
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGILL: CInterop.Signal { SIGILL }
|
||||
/// trace trap (not reset when caught)
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGTRAP: CInterop.Signal { SIGTRAP }
|
||||
/// abort()
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGABRT: CInterop.Signal { SIGABRT }
|
||||
#if false
|
||||
/// pollable event
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGPOLL: CInterop.Signal { SIGPOLL }
|
||||
#endif
|
||||
/// compatibility
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGIOT: CInterop.Signal { SIGIOT }
|
||||
/// EMT instruction
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGEMT: CInterop.Signal { SIGEMT }
|
||||
/// floating point exception
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGFPE: CInterop.Signal { SIGFPE }
|
||||
/// kill (cannot be caught or ignored)
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGKILL: CInterop.Signal { SIGKILL }
|
||||
/// bus error
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGBUS: CInterop.Signal { SIGBUS }
|
||||
/// segmentation violation
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGSEGV: CInterop.Signal { SIGSEGV }
|
||||
/// bad argument to system call
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGSYS: CInterop.Signal { SIGSYS }
|
||||
/// write on a pipe with no one to read it
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGPIPE: CInterop.Signal { SIGPIPE }
|
||||
/// alarm clock
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGALRM: CInterop.Signal { SIGALRM }
|
||||
/// software termination signal from kill
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGTERM: CInterop.Signal { SIGTERM }
|
||||
/// urgent condition on IO channel
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGURG: CInterop.Signal { SIGURG }
|
||||
/// sendable stop signal not from tty
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGSTOP: CInterop.Signal { SIGSTOP }
|
||||
/// stop signal from tty
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGTSTP: CInterop.Signal { SIGTSTP }
|
||||
/// continue a stopped process
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGCONT: CInterop.Signal { SIGCONT }
|
||||
/// to parent on child stop or exit
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGCHLD: CInterop.Signal { SIGCHLD }
|
||||
/// to readers pgrp upon background tty read
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGTTIN: CInterop.Signal { SIGTTIN }
|
||||
/// like TTIN for output if (tp->t_local<OSTOP)
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGTTOU: CInterop.Signal { SIGTTOU }
|
||||
/// input/output possible signal
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGIO: CInterop.Signal { SIGIO }
|
||||
/// exceeded CPU time limit
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGXCPU: CInterop.Signal { SIGXCPU }
|
||||
/// exceeded file size limit
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGXFSZ: CInterop.Signal { SIGXFSZ }
|
||||
/// virtual time alarm
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGVTALRM: CInterop.Signal { SIGVTALRM }
|
||||
/// profiling time alarm
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGPROF: CInterop.Signal { SIGPROF }
|
||||
/// window size changes
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGWINCH: CInterop.Signal { SIGWINCH }
|
||||
/// information request
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGINFO: CInterop.Signal { SIGINFO }
|
||||
/// user defined signal 1
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGUSR1: CInterop.Signal { SIGUSR1 }
|
||||
/// user defined signal 2
|
||||
@_alwaysEmitIntoClient
|
||||
internal var _SIGUSR2: CInterop.Signal { SIGUSR2 }
|
||||
#endif
|
||||
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2020 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
import Darwin
|
||||
#endif
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
public struct Signal: RawRepresentable {
|
||||
/// The raw C signal value.
|
||||
@_alwaysEmitIntoClient
|
||||
public let rawValue: CInterop.Signal
|
||||
|
||||
/// Creates a strongly typed signal from a raw C signal value.
|
||||
@_alwaysEmitIntoClient
|
||||
public init(rawValue: CInterop.Signal) { self.rawValue = rawValue }
|
||||
}
|
||||
#endif
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
extension Signal {
|
||||
/// The corresponding C signal is `SIGHUP`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var hangup: Self { Self(rawValue: _SIGHUP) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "hangup")
|
||||
internal static var SIGHUP: Self { hangup }
|
||||
|
||||
/// The corresponding C signal is `SIGINT`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var interrupt: Self { Self(rawValue: _SIGINT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "interrupt")
|
||||
internal static var SIGINT: Self { interrupt }
|
||||
|
||||
/// The corresponding C signal is `SIGQUIT`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var quit: Self { Self(rawValue: _SIGQUIT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "quit")
|
||||
internal static var SIGQUIT: Self { quit }
|
||||
|
||||
/// The corresponding C signal is `SIGILL`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var illegalInstruction: Self { Self(rawValue: _SIGILL) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "illegalInstruction")
|
||||
internal static var SIGILL: Self { illegalInstruction }
|
||||
|
||||
/// The corresponding C signal is `SIGTRAP`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var trap: Self { Self(rawValue: _SIGTRAP) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "trap")
|
||||
internal static var SIGTRAP: Self { trap }
|
||||
|
||||
/// The corresponding C signal is `SIGABRT`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var abort: Self { Self(rawValue: _SIGABRT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "abort")
|
||||
internal static var SIGABRT: Self { abort }
|
||||
|
||||
#if false
|
||||
/// The corresponding C signal is `SIGPOLL`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var pollableEvent: Self { Self(rawValue: _SIGPOLL) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "pollableEvent")
|
||||
internal static var SIGPOLL: Self { pollableEvent }
|
||||
#endif
|
||||
|
||||
/// The corresponding C signal is `SIGIOT`.
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, deprecated, renamed: "abort")
|
||||
internal static var inputOutputTrap: Self { Self(rawValue: _SIGIOT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, deprecated)
|
||||
@available(*, unavailable, renamed: "inputOutputTrap")
|
||||
internal static var SIGIOT: Self { inputOutputTrap }
|
||||
|
||||
/// The corresponding C signal is `SIGEMT`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var emulatorTrap: Self { Self(rawValue: _SIGEMT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "emulatorTrap")
|
||||
internal static var SIGEMT: Self { emulatorTrap }
|
||||
|
||||
/// The corresponding C signal is `SIGFPE`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var floatingPointException: Self { Self(rawValue: _SIGFPE) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "floatingPointException")
|
||||
internal static var SIGFPE: Self { floatingPointException }
|
||||
|
||||
/// The corresponding C signal is `SIGKILL`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var kill: Self { Self(rawValue: _SIGKILL) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "kill")
|
||||
internal static var SIGKILL: Self { kill }
|
||||
|
||||
/// The corresponding C signal is `SIGBUS`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var busError: Self { Self(rawValue: _SIGBUS) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "busError")
|
||||
internal static var SIGBUS: Self { busError }
|
||||
|
||||
/// The corresponding C signal is `SIGSEGV`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var segmentationViolation: Self { Self(rawValue: _SIGSEGV) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "segmentationViolation")
|
||||
internal static var SIGSEGV: Self { segmentationViolation }
|
||||
|
||||
/// The corresponding C signal is `SIGSYS`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var badSystemCall: Self { Self(rawValue: _SIGSYS) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "badSystemCall")
|
||||
internal static var SIGSYS: Self { badSystemCall }
|
||||
|
||||
/// The corresponding C signal is `SIGPIPE`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var brokenPipe: Self { Self(rawValue: _SIGPIPE) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "brokenPipe")
|
||||
internal static var SIGPIPE: Self { brokenPipe }
|
||||
|
||||
/// The corresponding C signal is `SIGALRM`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var alarm: Self { Self(rawValue: _SIGALRM) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "alarm")
|
||||
internal static var SIGALRM: Self { alarm }
|
||||
|
||||
/// The corresponding C signal is `SIGTERM`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var terminationRequest: Self { Self(rawValue: _SIGTERM) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "terminationRequest")
|
||||
internal static var SIGTERM: Self { terminationRequest }
|
||||
|
||||
/// The corresponding C signal is `SIGURG`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var urgentInputOutput: Self { Self(rawValue: _SIGURG) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "urgentInputOutput")
|
||||
internal static var SIGURG: Self { urgentInputOutput }
|
||||
|
||||
/// The corresponding C signal is `SIGSTOP`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var stop: Self { Self(rawValue: _SIGSTOP) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "stop")
|
||||
internal static var SIGSTOP: Self { stop }
|
||||
|
||||
/// The corresponding C signal is `SIGTSTP`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var interactiveStop: Self { Self(rawValue: _SIGTSTP) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "interactiveStop")
|
||||
internal static var SIGTSTP: Self { interactiveStop }
|
||||
|
||||
/// The corresponding C signal is `SIGCONT`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var `continue`: Self { Self(rawValue: _SIGCONT) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "continue")
|
||||
internal static var SIGCONT: Self { `continue` }
|
||||
|
||||
/// The corresponding C signal is `SIGCHLD`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var childStopOrExit: Self { Self(rawValue: _SIGCHLD) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "childStopOrExit")
|
||||
internal static var SIGCHLD: Self { childStopOrExit }
|
||||
|
||||
/// The corresponding C signal is `SIGTTIN`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var backgroundRead: Self { Self(rawValue: _SIGTTIN) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "backgroundRead")
|
||||
internal static var SIGTTIN: Self { backgroundRead }
|
||||
|
||||
/// The corresponding C signal is `SIGTTOU`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var backgroundWrite: Self { Self(rawValue: _SIGTTOU) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "backgroundWrite")
|
||||
internal static var SIGTTOU: Self { backgroundWrite }
|
||||
|
||||
/// The corresponding C signal is `SIGIO`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var possibleInputOutput: Self { Self(rawValue: _SIGIO) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "possibleInputOutput")
|
||||
internal static var SIGIO: Self { possibleInputOutput }
|
||||
|
||||
/// The corresponding C signal is `SIGXCPU`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var exceededCPUTimeLimit: Self { Self(rawValue: _SIGXCPU) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "exceededCPUTimeLimit")
|
||||
internal static var SIGXCPU: Self { exceededCPUTimeLimit }
|
||||
|
||||
/// The corresponding C signal is `SIGXFSZ`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var exceededFileSizeLimit: Self { Self(rawValue: _SIGXFSZ) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "exceededFileSizeLimit")
|
||||
internal static var SIGXFSZ: Self { exceededFileSizeLimit }
|
||||
|
||||
/// The corresponding C signal is `SIGVTALRM`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var virtualAlarm: Self { Self(rawValue: _SIGVTALRM) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "virtualAlarm")
|
||||
internal static var SIGVTALRM: Self { virtualAlarm }
|
||||
|
||||
/// The corresponding C signal is `SIGPROF`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var profilingAlarm: Self { Self(rawValue: _SIGPROF) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "profilingAlarm")
|
||||
internal static var SIGPROF: Self { profilingAlarm }
|
||||
|
||||
/// The corresponding C signal is `SIGWINCH`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var windowSizeChange: Self { Self(rawValue: _SIGWINCH) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "windowSizeChange")
|
||||
internal static var SIGWINCH: Self { windowSizeChange }
|
||||
|
||||
/// The corresponding C signal is `SIGINFO`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var informationRequest: Self { Self(rawValue: _SIGINFO) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "informationRequest")
|
||||
internal static var SIGINFO: Self { informationRequest }
|
||||
|
||||
/// The corresponding C signal is `SIGUSR1`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var userDefined1: Self { Self(rawValue: _SIGUSR1) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "userDefined1")
|
||||
internal static var SIGUSR1: Self { userDefined1 }
|
||||
|
||||
/// The corresponding C signal is `SIGUSR2`.
|
||||
@_alwaysEmitIntoClient
|
||||
internal static var userDefined2: Self { Self(rawValue: _SIGUSR2) }
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@available(*, unavailable, renamed: "userDefined2")
|
||||
internal static var SIGUSR2: Self { userDefined2 }
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2020 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
import Darwin
|
||||
#endif
|
||||
|
||||
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
|
||||
public struct SignalSet {
|
||||
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user