SIGINT 在 NT 本机 API 中翻译成什么?
Windows 支持控制台中的 SIGINT应用程序响应 Ctrl-C。这意味着 Windows 具有从远程线程中断正在运行的线程(甚至是进程!)并调用信号处理程序的功能。
这在 NT Native API 级别到底是如何工作的?这个线程中断 API 可以在用户空间中用于其他目的吗?
Windows has support for SIGINT in console applications in response to Ctrl-C. This implies Windows has functionality to interrupt a running thread from a remote thread (process even!) and invoke a signal handler.
Exactly how does this work at the NT Native API level? Can this thread-interruption API be used for other purposes in userspace?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 http://msdn.microsoft.com /en-us/library/xdkz3x12(v=vs.71).aspx,SIGINT 会导致创建一个新线程来处理中断。
所以看起来它并没有真正“中断”任何正在运行的线程。您可以通过简单地生成自己的线程来实现相同的效果。
这里有更多评论:
According to http://msdn.microsoft.com/en-us/library/xdkz3x12(v=vs.71).aspx, a SIGINT causes a new thread to be created to handle the interrupt.
So it looks like it doesn't really "interrupt" any running threads. You can achieve the same effect by simply spawning your own thread.
There is more commentary here:
您始终可以挂起目标线程,修复上下文以执行您的过程,然后恢复它。它很丑陋,但如果您想中断线程来执行过程,它会起作用。
控制台和 CTRL+C 处理程序是 Win32 构造,并不真正存在于本机 API 级别。
You could always suspend the target thread, fix up the context to execute your procedure and then resume it. It's ugly but it would work if you wanted to interrupt a thread to execute a procedure.
The console and the CTRL+C handler are Win32 constructs and do't really exist at the native API level.