Class CellOrphanWatch
零孤儿看门狗(§6.1——--parent-pid 1s 轮询,父死回调)。
单一实现:CLI 引导器与消费侧自有 exe 壳(嵌入 RunAsync(CellBootArgs, TextWriter?, TextWriter?, CellRuntimeOptions?, CancellationToken),§13 映射)
同路径——宿主形态不二份实现,孤儿策略不随宿主形态漂移。
public static class CellOrphanWatch
- Inheritance
-
CellOrphanWatch
- Inherited Members
Fields
DefaultPollInterval
缺省轮询间隔(§8 孤儿轮询 1s)。
public static readonly TimeSpan DefaultPollInterval
Field Value
Methods
IsAlive(int)
父进程存活判定(pid 不存在/已退出=死;探测异常=死——fail-closed,不赌平台差异)。
public static bool IsAlive(int pid)
Parameters
pidint
Returns
Start(int, Action, TimeSpan?)
启动父进程存活看门狗(专用后台线程——不占线程池、不受池饥饿拖累)。
父死即调 onParentDead(看门狗线程上下文):RunAsync 缺省处置=
Exit(int)(0) 按 §6.1 父死自杀——容器进程必须死,嵌入壳同受进程级契约约束。
返回 IDisposable=停表(置停后不再回调;进程级看门狗通常无需停)。
public static IDisposable Start(int parentPid, Action onParentDead, TimeSpan? pollInterval = null)