[New-bugs-announce] [issue14228] SIGINT (Ctrl-C) not caught at startup

telmich report at bugs.python.org
Thu Mar 8 10:05:36 CET 2012


New submission from telmich <nico-bugs.python.org at schottelius.org>:

Hello,

pressing ctrl-c or having sigint delivered to the python process in its startup phase results in random tracebacks displayed.

This is related to issue3137, but actually happening in Python 3.2.2 on archlinux.

We noticed this during development of the cdist project (http://www.nico.schottelius.org/software/cdist/), where we call a shell via subprocess.check_call() which calls us again (under a different name and thus different behaviour.

So the call chain is like this:

cdist => /bin/sh -e script => cdist_as_different_name (i.e. __file)

A simple test case to reproduce the problem needs the two files caller.py and shellpart.sh in a directory:

% ln -s caller.py __testpython
% chmod a+x *
% ./caller.py                 
Indirect child being called
Indirect child being called
Indirect child being called
Indirect child being called
^Ccaught signint in parent
Traceback (most recent call last):
  File "/usr/lib/python3.2/site.py", line 58, in <module>
    import traceback
  File "/usr/lib/python3.2/traceback.py", line 3, in <module>
    import linecache
  File "/usr/lib/python3.2/linecache.py", line 10, in <module>
    import tokenize
  File "/usr/lib/python3.2/tokenize.py", line 28, in <module>
    import re                                                                                                         
  File "/usr/lib/python3.2/re.py", line 121, in <module>
[10:02] brief:python-traceback-test%     import functools
  File "/usr/lib/python3.2/functools.py", line 2, in <module>
    """
KeyboardInterrupt


Pressing Ctrl-C results in various different tracebacks and I don't see any way to catch the SIGINT reliably currently, as the code executed seems to be *before* my code is being executed.

There is another related bug at debian that references the same problem:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652926

----------
files: shellpart.sh
messages: 155152
nosy: telmich
priority: normal
severity: normal
status: open
title: SIGINT (Ctrl-C) not caught at startup
type: crash
versions: Python 3.2
Added file: http://bugs.python.org/file24755/shellpart.sh

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14228>
_______________________________________


More information about the New-bugs-announce mailing list