def _errno_location():
"""
Try to get errno integer from libc using __errno_location_sym function.
This function is specific to OS with "libc.so.6" and may fails for
thread-safe libc.
"""
from ctypes import cdll
try:
libc = cdll.LoadLibrary("libc.so.6")
except OSError:
# Unable to open libc dynamic library
return None
try:
__errno_location = libc.__errno_location_sym
except AttributeError:
# libc doesn't have __errno_location
return None
__errno_location.restype = POINTER(c_int)
return __errno_location()[0]
评论列表
文章目录