[Neo-report] r2063 vincent - /trunk/neo/live_debug.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue May 4 18:36:16 CEST 2010
Author: vincent
Date: Tue May 4 18:36:16 2010
New Revision: 2063
Log:
Save and restore errno value around sighandler.
The signal is often received during epoll_wait call, and python code later
checks the value of libc's errno. That value might get tainted by
sighandler, causing errors to be detected after the call (epoll_wait would
return -1 as the call was interrupted by the signal).
Modified:
trunk/neo/live_debug.py
Modified: trunk/neo/live_debug.py
==============================================================================
--- trunk/neo/live_debug.py [iso-8859-1] (original)
+++ trunk/neo/live_debug.py [iso-8859-1] Tue May 4 18:36:16 2010
@@ -17,6 +17,7 @@
import traceback
import signal
+import ctypes
import imp
import neo
import pdb
@@ -38,14 +39,20 @@
# SIGUSR2:
# Triggers a pdb prompt on process' controlling TTY.
+libc = ctypes.cdll.LoadLibrary('libc.so.6')
+errno = ctypes.c_int.in_dll(libc, 'errno')
+
def decorate(func):
def decorator(sig, frame):
+ # Save errno value, to restore it after sig handler returns
+ old_errno = errno.value
try:
func(sig, frame)
except:
# Prevent exception from exiting signal handler, so mistakes in
# "debug" module don't kill process.
traceback.print_exc()
+ errno.value = old_errno
@decorate
def debugHandler(sig, frame):
More information about the Neo-report
mailing list