From: Angus on 23 Apr 2010 09:25 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
|
Pages: 1 Prev: How many threads can be handled by the OS scheduler? Next: CTreeCtrl : images on items |