Package: command-not-found
Version: 0.2.38-1

I mistyped, and when I realised I pressed ^C.  The result was this
transcript:

 zealot:~> P
 ^P^P^C
 zealot:~> Traceback (most recent call last):
   File "/usr/lib/command-not-found", line 12, in <module>
     from optparse import OptionParser
   File "/usr/lib/python2.6/optparse.py", line 22, in <module>
     """
 KeyboardInterrupt

This happens because the Python interpreter arranges (during its
startup) to trap SIGINT and turn it into a KeyboardInterrupt
exception.  If this happens before the execution of the part of the
script (if any) which takes countermeasures, the result is that the
interpreter prints the stack traceback to stderr and exits with status 1.

It is possible to reduce but not eliminate the time window during
which this will happen, by using Python's signal handling machinery to
put SIGINT back to SIG_DFL.

I can reproduce this and various other similar misbehaviours quite
easily: run 9 copies of "while true; do :; done &" and then in another
window type "spongex", press return, and then shortly afterwards (a
fraction of a second) press ^C.  (For reference, on a Dell Latitude
2120, which shows four 1.5GHz Atom N550 cores.)

I think it is not possible to fix this in command-not-found without
changes to Python; but for compatibility it's probably not possible to
fix this in Python without a change to command-not-found.

So I'm going to file a bug about the Python problem and block this bug
with that one.

In the meantime adding, right at the very top of the script,

  import signal
  signal.signal(signal.SIGINT, signal.SIG_DFL)

will reduce the window of vulnerability.

-- 
Ian Jackson                  personal email: <[email protected]>
These opinions are my own.        http://www.chiark.greenend.org.uk/~ijackson/
PGP2 key 1024R/0x23f5addb,     fingerprint 5906F687 BD03ACAD 0D8E602E FCF37657



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to