ctypes_errno.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:darkc0de-old-stuff 作者: tuwid 项目源码 文件源码
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]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号