mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-02 11:01:53 +08:00
using only find_library()
This commit is contained in:
@@ -48,22 +48,9 @@ from .logging import get_logger
|
|||||||
|
|
||||||
# =====
|
# =====
|
||||||
def _load_libc() -> ctypes.CDLL:
|
def _load_libc() -> ctypes.CDLL:
|
||||||
try:
|
path = ctypes.util.find_library("c")
|
||||||
path = ctypes.util.find_library("c")
|
if path:
|
||||||
except (OSError, IOError, RuntimeError):
|
return ctypes.CDLL(path)
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if path:
|
|
||||||
return ctypes.CDLL(path)
|
|
||||||
|
|
||||||
names = ["libc.so", "libc.so.6", "libc.so.0"]
|
|
||||||
for (index, name) in enumerate(names):
|
|
||||||
try:
|
|
||||||
return ctypes.CDLL(name)
|
|
||||||
except (OSError, IOError):
|
|
||||||
if index == len(names) - 1:
|
|
||||||
raise
|
|
||||||
|
|
||||||
raise RuntimeError("Where is libc?")
|
raise RuntimeError("Where is libc?")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user