[Python-Dev] C bindings calling tmpfile() blocks interrupt signal

Michael Hudson mwh at python.net
Thu Jul 7 14:58:23 CEST 2005


Florent Pillet <fpillet at gmail.com> writes:

> I discovered an issue on Mac OS X that seems to relate to signal
> handling. I have a C binding in which I call the standard tmpfile()
> function. After calling it, I can't break Python anymore with CTRL-C.

> Investigating the Darwin source code for tmpfile() (and FreeBSD, they
> are the same) , I found that the function is mucking with the signals:
>
> http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdio/tmpfile.c?rev=1.9&content-type=text/x-cvsweb-markup
>
> Is this considered a Python issue, or an OS issue? 

Um, I don't know.  That function certainly looks like it's trying to
pt the signal mask back.

> I ran a simple test against the interrupt signal, which didn't show
> any wrong behavior:
>
> static void intcatcher(int sig) {
>     printf("Interrupt catched\n");
>     exit(1);
> }
> int main(int argc, char **argv) {
>     signal(SIGINT, intcatcher);
>     printf("Press CTRL-C to interrupt...\n");
>     tmpfile();
>     while (1)
>         ;
>     return 0;
> }
>
> But with my threaded Python code, SIGINT doesn't work anymore after my
> binding has called tmpfile().

Oh, threads.

Which version of Python are you using?

Cheers,
mwh

-- 
  > So what does "abc" / "ab" equal?
  cheese
         -- Steve Holden defends obscure semantics on comp.lang.python


More information about the Python-Dev mailing list