How to deal with console clenaup before first dll unloads RRS feed

  • Pregunta

  • Hi,

    I'm using libavcodec to encode video. I need to handle a console program end (close) to terminate files graceful. The problem is that when I use atexit, _onexit, #pragma exit at that time external libraries are unloaded and calls to them make functions atexit,_onexit abort. Is there any way to handle consoleprogram end before it unloads his dynamic loaded libraries?


    Edit: I've also tryed SetConsoleCtrlHandler and has the same behaivour that atexit,_onexit.



    • Editado marranxo lunes, 1 de agosto de 2011 11:42
    lunes, 1 de agosto de 2011 11:10

Todas las respuestas

  • At the moment I can handle some close reasons, like signals SIGINT/SIGTERM. The problem is that hitting close buttonn (X) doesn't send either SIGINT or SIGTERM signal. In the other hand SetConsoleCtrlHandler handles it but when dlls are already unloaded. Anyone has an idea?
    lunes, 1 de agosto de 2011 11:42
  • Only as a suggestion: try to use a dummy class into main function and use the class destructor to unload DLL when class go out of scope.


    MVP Visual C++ - Visita mi blog sobre desarrollo:
    sábado, 20 de agosto de 2011 23:28