On Jun 2, 2013 10:06 AM, "Marc Weber" <[email protected]> wrote:
>
> The simple test case (bottom) is interruptable, while catching sigint
using a
> signal handler
>
> This patch tries to catch all common cases by replacing
> got_int = TRUE with my own function. I didn't catch all, only those who
seemed
> related to ctrl-c (by comments):
> http://mawercer.de/tmp/attempt-python-interrupt.patch
>
> However I fail to catch ctrl-c after :py and in console.
>
> Does somebody just know what I'm still missing?
>
> Marc Weber

Of course, this does not work. You need to have input eventloop running in
a different thread to make this work, thus it maybe will work in the GUI
(but maybe not, I do not know these files good), but definitely not in
console. Your example uses SIGINT though and it would work if you somehow
replace currently used SIG_INT with another handler. There are some
questions to answer though:

1. Will Vim receive CTRL-C as CTRL-C in case of existing handler.
2. If not how are you going to distinguish SIGINT created by kill -INT and
by CTRL-C.
3. If not how are you going to handle different stty intr setting (I guess
it is easy, but you need to remember about this).
4. If not how you would handle the case when interrupt was received in the
middle of updating input queue data structures.

3 and 4 must be relatively easy to answer, but I know nothing about 2.

> == simple test case
>
> #include <Python.h>
> #include "stdio.h"
> // #include "stdlib.h"
> #include "signal.h"
>
>
> void siginthandler(int param)
> {
>   //  PyErr_SetNone(PyExc_KeyboardInterrupt);
>   PyErr_SetInterrupt();
>   // PyErr_SetString(PyExc_RuntimeError, "user interrupted");
>   // PyErr_SetNone(PyExc_KeyboardInterrupt);
>   // Py_MakePendingCalls();
>   printf("User pressed Ctrl+C\n");
> }
>
> int
> main(int argc, char *argv[])
> {
>
>   char * command =
>   "while True:\n"
>   "  l = 1\n";
>
>   signal(SIGINT, siginthandler);
>
>   PyCompilerFlags cf;
>   cf.cf_flags = 0;
>
>   Py_SetProgramName(argv[0]);  /* optional but recommended */
>   Py_Initialize();
>   printf("running loop\n");
>   // PyRun_SimpleString(
>   //   ""
>   // );
>
>   PyRun_SimpleStringFlags(command , &cf);
>   // sts = PyRun_AnyFileFlags(stdin, "<stdin>", &cf) != 0;
>
>   Py_Finalize();
>   return 0;
> }
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
"vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui