KeyboardInterrupt from syscalls

Discussion in 'Python' started by Fredrik Tolf, Nov 22, 2006.

  1. Fredrik Tolf

    Fredrik Tolf Guest

    Dear List,

    I was writing a Python extension module, including a sleeping call to
    poll(2), and noticed, to my great surprise (and joy), that even when
    blocking there, KeyboardInterrupt still worked properly when sending
    SIGINTs to the interpreter. It really got me wondering how it works,
    though.

    I would have thought that I would have to check manually for interrupts
    in one way or another, seeing how the thread in question should be stuck
    in my syscall. Sure, I return on EINTR, but I only return Py_FALSE, not
    NULL, so I wouldn't have thought that the interpreter would look for an
    exception having taken place (I would assume that it gets set in the
    sighandler).

    So how does it work? Does my code get to return Py_FALSE, and the
    interpreter ignores it, seeing that an exception is set? Is a non-local
    exit performed right over my call stack (in which case my next question
    would be how to clean up resources being used from my C code)? Or does
    something completely else happen?

    Fredrik Tolf
    Fredrik Tolf, Nov 22, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan van Mansum

    syscalls.h or equivalent in cygwin or Linux

    Jan van Mansum, Jun 5, 2004, in forum: C Programming
    Replies:
    4
    Views:
    3,694
    Jan van Mansum
    Jun 5, 2004
  2. Steve Holden

    ASP KeyboardInterrupt errors

    Steve Holden, Jun 24, 2003, in forum: Python
    Replies:
    2
    Views:
    719
    Mark Hammond
    Jun 28, 2003
  3. Ivan Nestlerode

    KeyboardInterrupt and threading

    Ivan Nestlerode, Jan 2, 2004, in forum: Python
    Replies:
    8
    Views:
    520
    Anand Pillai
    Jan 8, 2004
  4. PantherSE
    Replies:
    0
    Views:
    335
    PantherSE
    May 16, 2005
  5. Curt Sampson

    Signals and Restarting Syscalls

    Curt Sampson, Jan 7, 2007, in forum: Ruby
    Replies:
    0
    Views:
    90
    Curt Sampson
    Jan 7, 2007
Loading...

Share This Page