Re[2]: Kill process group after a timeout window
"Laurent Bercot" <[email protected]> Fri, 07 Nov 2025 12:41:29 +0000
| Newsgroups | gmane.comp.sysutils.supervision.general |
|---|---|
| Message-ID | <[email protected]> |
>>#!/bin/sh >>sleep 2 >>kill -9 -- -"$4" > >I=E2=80=99m not sure this is correct, the finish script is only run once t= he process is down, so the waiting period is actually determined by the val= ue in the timeout-kill file (or potentially another s6-svc -k command) and= not by the sleep in the finish script as far as I can tell. timeout-kill is only applicable to the main process. If the main process takes too long to die, s6-supervise will send it a SIGKILL after timeout-kill milliseconds. IIUC what you have said, the main process is *not* the issue here, it dies gracefully every time. The problem is that occasionally, a child remains alive. timeout-kill will not catch this. As soon as the main process dies, the service is considered down, and the finish script=20 runs, even if there still are children of your daemon around. If your main process dies before timeout-kill, no s6-svc -k is sent at all. The sleep is meant to give these children some time to die gracefully after the main process is down. The majority of them, behaving properly, will do so quickly. The buggy ones will remain, and that's why you need a kill command, *in the finish script*, to clean up. >For some reason I don=E2=80=99t think the =E2=80=94 seperating options and = arguments is needed in kill, it seems to interpret the group id as an argu= ment anyway as long as I=E2=80=99ve supplied a signal. It may not be necessary with your implementation of kill, but it is good practice to do so anyway when an argument starts with a dash. The specification explicitly recommends it for kill: "If the first pid operand is negative, it should be preceded by "--" to keep it from being interpreted as an option." https://pubs.opengroup.org/onlinepubs/9799919799/utilities/kill.html Glad it's working for you! -- Laurent