chiark / gitweb /
fishdescriptor: Use os or dl for RTLD_now
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:11:13 +0000 (19:11 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 6 Oct 2017 18:11:13 +0000 (19:11 +0100)
Suggestion by Colin Watson.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
fishdescriptor/greenend/fishdescriptor/indonor.py

index b9e9053191cc41a1f04d2c906393f811f8060317..f77a4daa9e0d855983bc69cf55b31810288ae891 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)