File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ int (*sd_session_get_start_time)(const char *, uint64_t *);
21
21
int (* sd_session_get_tty )(const char * , char * * );
22
22
int (* sd_session_get_username )(const char * , char * * );
23
23
24
+ // Handle for the libsystemd library
25
+ void * HANDLE = NULL ;
26
+
24
27
25
28
#define dlsym_check (__h , __fn , __name ) do { \
26
29
__fn = dlsym(__h, #__fn); \
@@ -34,7 +37,12 @@ int (*sd_session_get_username)(const char *, char **);
34
37
35
38
static void *
36
39
load_systemd () {
37
- void * handle = dlopen ("libsystemd.so.0" , RTLD_LAZY );
40
+ void * handle = NULL ;
41
+
42
+ if (HANDLE != NULL )
43
+ return HANDLE ;
44
+
45
+ handle = dlopen ("libsystemd.so.0" , RTLD_LAZY );
38
46
if (dlerror () != NULL || handle == NULL ) {
39
47
psutil_debug ("can't open libsystemd.so.0" );
40
48
return NULL ;
@@ -53,7 +61,9 @@ load_systemd() {
53
61
dlclose (handle );
54
62
return NULL ;
55
63
}
56
- return handle ;
64
+
65
+ HANDLE = handle ;
66
+ return HANDLE ;
57
67
}
58
68
59
69
PyObject *
You can’t perform that action at this time.
0 commit comments