The idea is to set an internal control event handler, rather than using the default one (that kills the cli).
the new handler should pass the ctrl-c event to the python child pid, by using GenerateConsoleCtrlEvent.
the new handler is set by using SetConsoleCtrlHandler.
so you need a control handler function, and to set it up.
you also need the child pid (to send the ctrl-c to), but spawnv doesn't return it. so you also need to move to CreateProcessA and WaitForSingleObject.
in order to use CreateProcess, you need to convert ptr and newchars into one big char*.
Attached is a patch draft, just wrote it w/o compiling and making sure it really works.
|