Beispiel #1
0
 def get_open_fds():
     return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
         if fd.isdigit())
Beispiel #2
0
 def get_open_fds():
     return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
         if fd.isdigit())
Beispiel #3
0
    'easymgc.utils:logger',
)

from easymgc.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY
from easymgc.exception import CommandNotFound

try:
    import resource
    max_fd_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
except ImportError:
    max_fd_limit = 256

if sys.hexversion >= 0x3000000:
    basestring = str

if os.path.isdir("/proc/%i/fd" % os.getpid()):

    def get_open_fds():
        return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
            if fd.isdigit())

    if platform.python_implementation() == 'PyPy':
        # EAGAIN observed with PyPy 1.8.
        _get_open_fds = get_open_fds

        def get_open_fds():
            try:
                return _get_open_fds()
            except OSError as e:
                if e.errno != errno.EAGAIN:
                    raise
Beispiel #4
0
    'easymgc.utils:logger',
)

from easymgc.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY
from easymgc.exception import CommandNotFound

try:
    import resource
    max_fd_limit = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
except ImportError:
    max_fd_limit = 256

if sys.hexversion >= 0x3000000:
    basestring = str

if os.path.isdir("/proc/%i/fd" % os.getpid()):
    def get_open_fds():
        return (int(fd) for fd in os.listdir("/proc/%i/fd" % os.getpid()) \
            if fd.isdigit())

    if platform.python_implementation() == 'PyPy':
        # EAGAIN observed with PyPy 1.8.
        _get_open_fds = get_open_fds
        def get_open_fds():
            try:
                return _get_open_fds()
            except OSError as e:
                if e.errno != errno.EAGAIN:
                    raise
                return range(max_fd_limit)