What happens when you close a c++ console application

前端 未结 4 609
南笙
南笙 2020-11-28 12:00

I guess the question says it all, but, what happens if someone closes a c++ console app? As in, clicks the \"x\" in the top corner. Does it instantly close? Does it throw so

4条回答
  •  遥遥无期
    2020-11-28 12:33

    I imagine that the console process just gets unceremoniously killed by the OS. If you want to trap this event and do something it looks like the SetConsoleCtrlHandler function is the way to do it.

    See also:

    • How to handle a ctrl-break signal in a command line interface
    • Console Event Handling

提交回复
热议问题