chiark / gitweb /
fishdescriptor: Use os or dl for RTLD_now
[chiark-utils.git] / fishdescriptor / greenend / fishdescriptor / indonor.py
index b9e9053..f77a4da 100644 (file)
@@ -2,6 +2,19 @@
 # class for use inside gdb which is debugging the donor process
 
 import gdb
+import os
+
+try:
+    rtld_now = os.RTLD_NOW
+except AttributeError:
+    try:
+        import dl
+        rtld_now = dl.RTLD_NOW
+    except ImportError:
+        # some installations lack dl, it seems
+        # https://bugs.launchpad.net/ubuntu/+source/python2.7/+bug/1721840
+        # bodge:
+        rtld_now = 2
 
 def _string_escape_for_c(s):
     if not isinstance(s, bytes):
@@ -38,8 +51,6 @@ class DonorImplementation():
 
     def _dlopen(self):
         if self._open is not None: return
-        rtld_print_cmd = ['fishdescriptor','--print-rtld-now'];
-        rtld_now = subprocess.check_output(rtld_print_cmd).rstrip('\n')
         o = self._dlfunc('void* (*)(const char*, int)',
                          'dlopen',
                          '("libfishdescriptor-donate.so.1.0", %s)' % rtld_now)