XU XUv0.16.0

#os/signal

导入方式: #os/signal

公开 API: 5 函数, 2 方法, 1 类型, 8 常量, 0 方法集

Unix 信号编号。notify 未接到内核,调用即 throw,避免静默丢信号。

const SIGHUP

XuAPI
pub const SIGHUP = 1

用途

常量 SIGHUP,定义了相关的协议或算法配置参数。

const INTERRUPT

XuAPI
pub const INTERRUPT = 2

用途

常量 INTERRUPT,定义了相关的协议或算法配置参数。

const SIGINT

XuAPI
pub const SIGINT = 2

用途

常量 SIGINT,定义了相关的协议或算法配置参数。

const SIGQUIT

XuAPI
pub const SIGQUIT = 3

用途

常量 SIGQUIT,定义了相关的协议或算法配置参数。

const KILL

XuAPI
pub const KILL = 9

用途

常量 KILL,定义了相关的协议或算法配置参数。

const SIGKILL

XuAPI
pub const SIGKILL = 9

用途

常量 SIGKILL,定义了相关的协议或算法配置参数。

const SIGPIPE

XuAPI
pub const SIGPIPE = 13

用途

常量 SIGPIPE,定义了相关的协议或算法配置参数。

const SIGTERM

XuAPI
pub const SIGTERM = 15

用途

常量 SIGTERM,定义了相关的协议或算法配置参数。

struct Notifier

XuAPI
pub struct Notifier {
    pub ch chan int
    pub sig int
    pub active bool
}

用途

承载 ch、sig、active 等属性的结构体。

公开字段

ch chan int
字符码
sig int
字段(int)
active bool
字段(bool)

new_notifier

XuAPI
pub fn new_notifier(c chan int, sig int) Notifier

用途

构造 notifier。

参数

c chan int
字节或字符码(通道;类型 chan int)
sig int
sig(int)

返回值

Notifier — 该类型的值

($&Notifier) stop

XuAPI
pub fn (n $&Notifier) stop()

用途

$&Notifier 上的操作:停止。

参数

n $&Notifier
本次调用使用的 Notifier 实例;以独占借用传入,方法可修改它,调用方仍持有实例。

返回值

不返回值。

(&Notifier) raise

XuAPI
pub fn (n &Notifier) raise(sig int) bool

用途

在 &Notifier 上执行 raise 操作。

参数

n &Notifier
本次调用使用的 Notifier 实例;以只读借用传入,调用方仍持有实例。
sig int
sig(int)

返回值

bool — 是否成立

notify

XuAPI
pub fn notify(c chan int, sig int) int

用途

通知。失败时抛出错误,调用方需处理或继续传播。

参数

c chan int
字节或字符码(通道;类型 chan int)
sig int
sig(int)

返回值

int — 该类型的值

stop

XuAPI
pub fn stop(c chan int) int

用途

停止。

参数

c chan int
字节或字符码(通道;类型 chan int)

返回值

int — 该类型的值

ignore

XuAPI
pub fn ignore(sig int) int

用途

忽略。失败时抛出错误,调用方需处理或继续传播。

参数

sig int
sig(int)

返回值

int — 该类型的值

raise

XuAPI
pub fn raise(c chan int, sig int) bool

用途

执行 raise 处理。

参数

c chan int
字节或字符码(通道;类型 chan int)
sig int
sig(int)

返回值

bool — 是否成立