From: Angus on
Hello

On a Windows 2008 32 bit PC (I assume same for 64 bit) if user clicks
x on top right console window to close program, how do you intercept.
If I setup a handler for SIGINT, SIGTERM and SIGBREAK, the signal
handler is not called.

Here is my test program:
#include <csignal>
#include <iostream>
#include <ostream>
#include <string>
#include <fstream>

using namespace std;

namespace
{
volatile sig_atomic_t quit;

void signal_handler(int sig)
{
signal(sig, signal_handler);
quit = 1;
}
}

int main()
{
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGBREAK, signal_handler);

while (!quit)
{
string s;
cin >> s;
cout << s << endl;
}

ofstream myfile;
myfile.open ("sigtest.txt");
myfile << "quit = " << quit << endl;
myfile.close();
}

If user clicks x on Windows 2008 macihne, log file is not created.

Anyone know to intercept?

Angus