Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.142.54.254
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /srv/modoboa/env/lib64/python3.5/site-packages/gevent/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /srv/modoboa/env/lib64/python3.5/site-packages/gevent/tests//test__monkey_sigchld.py
import errno
import os
import sys
#os.environ['GEVENT_NOWAITPID'] = 'True'

import gevent
import gevent.monkey
gevent.monkey.patch_all()

pid = None
awaiting_child = []


def handle_sigchld(*_args):
    # Make sure we can do a blocking operation
    gevent.sleep()
    # Signal completion
    awaiting_child.pop()
    # Raise an ignored error
    raise TypeError("This should be ignored but printed")

import signal
if hasattr(signal, 'SIGCHLD'):
    assert signal.getsignal(signal.SIGCHLD) == signal.SIG_DFL
    signal.signal(signal.SIGCHLD, handle_sigchld)
    handler = signal.getsignal(signal.SIGCHLD)
    assert signal.getsignal(signal.SIGCHLD) is handle_sigchld, handler

    if hasattr(os, 'forkpty'):
        def forkpty():
            # For printing in errors
            return os.forkpty()[0]
        funcs = (os.fork, forkpty)
    else:
        funcs = (os.fork,)

    for func in funcs:
        awaiting_child = [True]
        pid = func()
        if not pid:
            # child
            gevent.sleep(0.3)
            sys.exit(0)
        else:
            timeout = gevent.Timeout(1)
            try:
                while awaiting_child:
                    gevent.sleep(0.01)
                # We should now be able to waitpid() for an arbitrary child
                wpid, status = os.waitpid(-1, os.WNOHANG)
                if wpid != pid:
                    raise AssertionError("Failed to wait on a child pid forked with a function",
                                         wpid, pid, func)

                # And a second call should raise ECHILD
                try:
                    wpid, status = os.waitpid(-1, os.WNOHANG)
                    raise AssertionError("Should not be able to wait again")
                except OSError as e:
                    assert e.errno == errno.ECHILD
            except gevent.Timeout as t:
                if timeout is not t:
                    raise
                raise AssertionError("Failed to wait using", func)
            finally:
                timeout.close()
    sys.exit(0)
else:
    print("No SIGCHLD, not testing")

Anon7 - 2022
AnonSec Team