def load_libc_function(func_name, log_error=True, fail_if_missing=False, errcheck=False):
 try:
  libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
  func = getattr(libc, func_name)
 except AttributeError:
  if fail_if_missing:
   raise
  if log_error:
   logging.warning(_('Unable to locate %s in libc.  Leaving as a no-op.'), func_name)
  return noop_libc_function
 if errcheck:
  def _errcheck(result, f, args):
   if (result == (-1)):
    errcode = ctypes.get_errno()
    raise OSError(errcode, os.strerror(errcode))
   return result
  func.errcheck = _errcheck
 return func

def load_libc_function ( func_name , log_error = True , fail_if_missing = False , errcheck = False ) : try : libc = ctypes . CDLL ( ctypes . util . find_library ( 'c' ) , use_errno = True ) func = getattr ( libc , func_name ) except AttributeError : if fail_if_missing : raise if log_error : logging . warning ( _ ( 'Unable to locate %s in libc.  Leaving as a no-op.' ) , func_name ) return noop_libc_function if errcheck : def _errcheck ( result , f , args ) : if ( result == ( - 1 ) ) : errcode = ctypes . get_errno ( ) raise OSError ( errcode , os . strerror ( errcode ) ) return result func . errcheck = _errcheck return func
attempt to find the function in libc .