문제

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?

도움이 되었습니까?

해결책

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:

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top