diff --git a/apps/dokploy/__test__/domain-overview/acme-delete-signals.test.ts b/apps/dokploy/__test__/domain-overview/acme-delete-signals.test.ts index cc86418b5a..39a9767c08 100644 --- a/apps/dokploy/__test__/domain-overview/acme-delete-signals.test.ts +++ b/apps/dokploy/__test__/domain-overview/acme-delete-signals.test.ts @@ -59,13 +59,21 @@ const recover = (shell: string, env: Record = {}) => { encoding: "utf8", env: baseEnv(env) }, ); +// A killed client whose parent shell was killed too is left to PID 1. In a +// container whose PID 1 never reaps (`sleep infinity`), it stays a zombie for +// good, and signal 0 still reaches a zombie, so it would count as running. const alive = (pid: number) => { try { process.kill(pid, 0); - return true; } catch { return false; } + try { + const stat = readFileSync(`/proc/${pid}/stat`, "utf8"); + return stat.slice(stat.lastIndexOf(")") + 2)[0] !== "Z"; + } catch { + return true; + } }; describe.skipIf(!REAL_JQ).each(SHELLS)( @@ -253,7 +261,9 @@ describe.skipIf(!REAL_JQ).each(SHELLS)( killLeftovers(); - await waitFor(() => !alive(pid)); + await waitFor( + () => job.child.signalCode !== null || job.child.exitCode !== null, + ); expect(job.child.signalCode).toBe("SIGKILL"); }); },