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


== 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.


Raspunde prin e-mail lui