Message157358
sudo breaks exception handling in Python in some subtle way. The following test program works fine when run directly, but breaks when run through sudo:
#!/usr/bin/python
import time
def a():
try:
while True:
time.sleep(0.001)
except KeyboardInterrupt:
print "a"
def b():
try:
a()
except KeyboardInterrupt:
print "b"
b()
This is expected:
pierre@pangolin:~$ ./test.py
^Ca
But through sudo you get random behaviour:
pierre@pangolin:~$ sudo ./test.py
^Ca b
pierre@pangolin:~$ sudo ./test.py
^Ca b
pierre@pangolin:~$ sudo ./test.py
^Ca
b
pierre@pangolin:~$ sudo ./test.py
^Ca
pierre@pangolin:~$ sudo ./test.py
^Ca
pierre@pangolin:~$ sudo ./test.py
^Cb
Seen on Ubuntu 12.04 (alpha/beta) and on Fedora 16. Happens more often on Ubuntu though. |
|
Date |
User |
Action |
Args |
2012-04-02 14:57:06 | ossman | set | recipients:
+ ossman |
2012-04-02 14:57:06 | ossman | set | messageid: <1333378626.33.0.624726791004.issue14476@psf.upfronthosting.co.za> |
2012-04-02 14:57:05 | ossman | link | issue14476 messages |
2012-04-02 14:57:05 | ossman | create | |
|