Hi all,

Sanda, I've tried your sample code but there is something that I still not understand or maybe this solution still does not work

On Windows I have added this small code part, just after releasing the semaphore :
Qt Code:
  1. qDeleteAll(threads);
  2.  
  3. QFile file("C:\\qtThreadEnded.txt");
  4. file.open(QIODevice::WriteOnly | QIODevice::Text);
  5. QTextStream out(&file);
  6. out << "Application closing PROPERLY !!!\n";
  7. file.flush();
  8. file.close();
To copy to clipboard, switch view to plain text mode 

Simply to write a file when the application exit. Here is the way I've test :
  1. Task Manager [End Task]
    • I open the task manager, I click on the console process line and then I click on "End Task" menu. Usually the WM_CLOSE is send but as we are in a console application, no windows will handle this message ? But, is Windows smart enough to send a SIGTERM instead ? Anyway the application is closing and I can confirm you is that NO file has been written C:\\qtThreadEnded.txt.
  2. X button of console Window
    • I've read somewhere that End Task and clicking the X Button of the console Application do the same kind of kill on Windows. The application is closing but Still NO file has been written C:\\qtThreadEnded.txt.
  3. CTRL+C
    • The break point set in the signalHandler is hit, good news ! But application is not closing and still NO file has been written C:\\qtThreadEnded.txt.


The fact that no file is written is indicating us that process is not exited as we WANT. The process is not waiting for thread to be stop, cleaning resource and stop process. Instead, the OS process closes abruptly the process.

I have not tried on Linux, this is my next step.
However, I want to thank you again for your help is much appreciated

Best regards,