不断死去的背景过程

2026年8月2日1 次浏览来源:Dev.to阅读原文

正文保留英文原文(机翻易破坏代码与排版),标题/摘要已提供中文

On Windows I kept launching background servers from a task runner and watching them die the instant the launching step finished — no error, no log, just gone.

The task runner was wrapping everything in a job object, and job-object teardown kills every child process on return.

Nothing I did inside the child mattered; its death warrant was signed by how it was born.

The workaround was to have the process created by something that outlives the runner — the OS scheduler, a WMI process-create call — instead of spawning it as a doomed descendant.

When a process keeps dying without a trace, look at its lineage before its code — some parents kill their children on the way out, and no amount of hardening inside the child fixes how it was spawned.

分享