[C++-sig] Why can't kill process by Ctrl-c in a boost.python module with an endless loop

simon zhang hapopen at gmail.com
Sun Dec 23 08:44:17 CET 2012


I have make a boost.python module with an endless loop.But I can't kill the
process by ctrl-c.The following is an example.

C++

#include <boost/python.hpp>#include <boost/python.module.hpp>#include
<boost/python.def.hpp>#include <iostream>
usring namespace boost::python;
void foo() {
   int it=0;
   while (true) {                     //endless loop
       ++it;
       std::cout<< it <<std::endl;
       sleep(3);
   }}

BOOST_PYTHON_MODULE(ctopy){
    def("foo",foo);}

python:

import ctopy
ctopy.foo()

result:

1234.....................

I can't kill the foreground process by Ctrl-c.why the module don't accept
signal "SIGINT" that was sent by Ctrl-c.How to make it work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20121223/188d4ce4/attachment.html>


More information about the Cplusplus-sig mailing list