Ctrl-C对C ++ Win32控制台应用程序有什么影响? [英] What exactly is the effect of Ctrl-C on C++ Win32 console applications?
问题描述
编辑:SIGINT,而不是SIGTERM。并且Assaf报告没有对象被破坏(至少在Windows上)的未处理SIGINT。
系统发送SIGINT。这个概念适用于所有C实现(有一些差异)。要处理它,你调用signal,指定一个信号处理程序。有关信号函数的文档,请参见打开组和 MSDN 。
第二个问题有点棘手,可能取决于实现。最好的办法是处理信号,允许您手动使用 delete
和 exit()
。 >
- Is it possible to handle this event in some way?
- What happens in terms of stack unwinding and deallocation of static/global objects?
EDIT: SIGINT, not SIGTERM. And Assaf reports that no objects are destroyed (at least on Windows) for unhanded SIGINT.
The system sends a SIGINT. This concept applies (with some variance) for all C implementations. To handle it, you call signal, specifying a signal handler. See the documentation on the signal function at Open Group and MSDN.
The second question is a little trickier, and may depend on implementation. The best bet is to handle the signal, which allows you to use delete
and exit()
manually.
这篇关于Ctrl-C对C ++ Win32控制台应用程序有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!