Question

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?

Was it helpful?

Solution

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:

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top