Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't SIGTERM Works On Windows [duplicate]

Tags:

c++

windows

Here is my code:

void signalHandler(int sigNum) {
    OutputDebugStringA("i'm terminated\n");
    exit(sigNum);
}

int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
    _In_opt_ HINSTANCE hPrevInstance,
    _In_ LPTSTR    lpCmdLine,
    _In_ int       nCmdShow)
{
    signal(SIGTERM, signalHandler);
    while (1)
    {
        Sleep(100);
    }
    return 0;
}

when i terminated it via the windows taskmgr,that DebugString did't show up. is something wrong with my code?

like image 825
H.C.Chou Avatar asked Sep 02 '25 06:09

H.C.Chou


1 Answers

Windows does not use signals in the same way that Unix systems do.

For example, it does not generate SIGTERM.

like image 172
Jesper Juhl Avatar answered Sep 04 '25 20:09

Jesper Juhl