예제 #1
0
파일: macutils.py 프로젝트: VHarisop/xonsh
def sysctlbyname(name, return_str=True):
    """Gets a sysctl value by name. If return_str is true, this will return
    a string representation, else it will return the raw value.
    """
    # forked from https://gist.github.com/pudquick/581a71425439f2cf8f09
    size = c_uint(0)
    # Find out how big our buffer will be
    LIBC.sysctlbyname(name, None, byref(size), None, 0)
    # Make the buffer
    buf = create_string_buffer(size.value)
    # Re-run, but provide the buffer
    LIBC.sysctlbyname(name, buf, byref(size), None, 0)
    if return_str:
        return buf.value
    else:
        return buf.raw
예제 #2
0
파일: macutils.py 프로젝트: sthagen/xonsh
def sysctlbyname(name, return_str=True):
    """Gets a sysctl value by name. If return_str is true, this will return
    a string representation, else it will return the raw value.
    """
    # forked from https://gist.github.com/pudquick/581a71425439f2cf8f09
    size = c_uint(0)
    # Find out how big our buffer will be
    LIBC.sysctlbyname(name, None, byref(size), None, 0)
    # Make the buffer
    buf = create_string_buffer(size.value)
    # Re-run, but provide the buffer
    LIBC.sysctlbyname(name, buf, byref(size), None, 0)
    if return_str:
        return buf.value
    else:
        return buf.raw
예제 #3
0
파일: jobs.py 프로젝트: VHarisop/xonsh
        def _pthread_sigmask(how, signals):
            mask = 0
            for sig in signals:
                mask |= 1 << sig
            oldmask = ctypes.c_ulong()
            mask = ctypes.c_ulong(mask)
            result = LIBC.pthread_sigmask(how, ctypes.byref(mask),
                                          ctypes.byref(oldmask))
            if result:
                raise OSError(result, 'Sigmask error.')

            return {sig for sig in getattr(signal, 'Signals', range(0, 65))
                    if (oldmask.value >> sig) & 1}
예제 #4
0
파일: jobs.py 프로젝트: t184256/xonsh
        def _pthread_sigmask(how, signals):
            mask = 0
            for sig in signals:
                mask |= 1 << sig
            oldmask = ctypes.c_ulong()
            mask = ctypes.c_ulong(mask)
            result = LIBC.pthread_sigmask(how, ctypes.byref(mask),
                                          ctypes.byref(oldmask))
            if result:
                raise OSError(result, "Sigmask error.")

            return {
                sig
                for sig in getattr(signal, "Signals", range(0, 65))
                if (oldmask.value >> sig) & 1
            }
예제 #5
0
파일: jobs.py 프로젝트: laerus/xonsh
 def give_terminal_to(pgid):
     omask = ctypes.c_ulong()
     mask = ctypes.c_ulong()
     LIBC.sigemptyset(ctypes.byref(mask))
     for i in _block_when_giving:
         LIBC.sigaddset(ctypes.byref(mask), ctypes.c_int(i))
     LIBC.sigemptyset(ctypes.byref(omask))
     LIBC.sigprocmask(ctypes.c_int(signal.SIG_BLOCK),
                      ctypes.byref(mask),
                      ctypes.byref(omask))
     LIBC.tcsetpgrp(ctypes.c_int(FD_STDERR), ctypes.c_int(pgid))
     LIBC.sigprocmask(ctypes.c_int(signal.SIG_SETMASK),
                      ctypes.byref(omask), None)
     return True
예제 #6
0
 def give_terminal_to(pgid):
     omask = ctypes.c_ulong()
     mask = ctypes.c_ulong()
     LIBC.sigemptyset(ctypes.byref(mask))
     for i in _block_when_giving:
         LIBC.sigaddset(ctypes.byref(mask), ctypes.c_int(i))
     LIBC.sigemptyset(ctypes.byref(omask))
     LIBC.sigprocmask(ctypes.c_int(signal.SIG_BLOCK),
                      ctypes.byref(mask), ctypes.byref(omask))
     LIBC.tcsetpgrp(ctypes.c_int(FD_STDERR), ctypes.c_int(pgid))
     LIBC.sigprocmask(ctypes.c_int(signal.SIG_SETMASK),
                      ctypes.byref(omask), None)
     return True