Commit ff968d44 authored by Vincent Pelletier's avatar Vincent Pelletier

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).

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2063 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent dfe60f81
......@@ -17,6 +17,7 @@
import traceback
import signal
import ctypes
import imp
import neo
import pdb
......@@ -38,14 +39,20 @@ ENABLED = False
# 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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment