system's "kill <pid>" signal

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 6 18:15:30 PST 2016


On 11/6/16 11:05 AM, Konstantin Kutsevalov wrote:
> On Saturday, 5 November 2016 at 07:52:53 UTC, Basile B. wrote:
>> On Saturday, 5 November 2016 at 06:17:51 UTC, Basile B. wrote:
>> 3rd option, from my Windows times I remember that people tend to use
>> launchers
>> to handle the real application, i.e a process that launches the main
>> process. Then the launcher can have a thread that checks the PID (like
>> in "After Term..."). If SIGKILL isn't handled by a signal() callback
>> then this could be an option.
>>
>> Do you have to check if a server crashes or something like that ?
>
> not a system crash. just a signal of sistems shutdown or process kill.

You can catch signals, but some the OS does not let you catch.

IIRC, Posix systems on shutdown first send a "TERM" signal (15) which is 
the default signal for the kill command line as well. If the process 
does not clean up within a certain timeout, then it is sent the "KILL" 
signal (9), which CANNOT be caught.

What you want is to handle process cleanup on the TERM signal.

-Steve


More information about the Digitalmars-d-learn mailing list