1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Index: python-ptrace/cptrace/cptrace.c
===================================================================
--- python-ptrace.orig/cptrace/cptrace.c 2012-04-28 12:03:07.145652296 +0200
+++ python-ptrace/cptrace/cptrace.c 2012-04-28 16:40:15.941112538 +0200
@@ -21,6 +21,7 @@
unsigned long *result)
{
unsigned long ret;
+ errno = 0;
ret = ptrace(request, pid, arg1, arg2);
if ((long)ret == -1) {
/**
Index: python-ptrace/ptrace/binding/func.py
===================================================================
--- python-ptrace.orig/ptrace/binding/func.py 2011-06-11 16:24:42.000000000 +0200
+++ python-ptrace/ptrace/binding/func.py 2012-04-28 16:40:25.897112573 +0200
@@ -118,6 +118,7 @@
except ImportError:
HAS_CPTRACE = False
from ctypes import c_long, c_ulong
+ from ctypes import get_errno, set_errno
from ptrace.ctypes_libc import libc
# Load ptrace() function from the system C library
@@ -134,6 +135,7 @@
errno = get_errno()
raise PtraceError(message, errno=errno, pid=pid)
else:
+ set_errno(0)
result = _ptrace(command, pid, arg1, arg2)
result_signed = c_long(result).value
if result_signed == -1:
Index: python-ptrace/ptrace/ctypes_libc.py
===================================================================
--- python-ptrace.orig/ptrace/ctypes_libc.py 2011-06-11 16:24:22.000000000 +0200
+++ python-ptrace/ptrace/ctypes_libc.py 2012-04-28 16:40:25.897112573 +0200
@@ -4,9 +4,9 @@
- libc: the loaded library
"""
-from ctypes import cdll
+from ctypes import CDLL
from ctypes.util import find_library
LIBC_FILENAME = find_library('c')
-libc = cdll.LoadLibrary(LIBC_FILENAME)
+libc = CDLL(LIBC_FILENAME, use_errno=True)
|