Exemple #1
0
 def test_exit(self):
     try:
         import posix, _rawffi
     except ImportError:
         skip("requires posix.fork() to test")
     #
     pid = posix.fork()
     if pid == 0:
         _rawffi.exit(5)   # in the child
     pid, status = posix.waitpid(pid, 0)
     assert posix.WIFEXITED(status)
     assert posix.WEXITSTATUS(status) == 5
Exemple #2
0
def handle_system_exit(e):
    # issue #1194: if we get SystemExit here, then exit the interpreter.
    # Highly obscure imho but some people seem to depend on it.
    if sys.flags.inspect:
        return  # Don't exit if -i flag was given.
    else:
        code = e.code
        if isinstance(code, int):
            exitcode = code
        else:
            f = getattr(sys, 'stderr', None)
            if f is None:
                f = sys.__stderr__
            print >> f, code
            exitcode = 1

        _rawffi.exit(exitcode)
Exemple #3
0
def handle_system_exit(e):
    # issue #1194: if we get SystemExit here, then exit the interpreter.
    # Highly obscure imho but some people seem to depend on it.
    if sys.flags.inspect:
        return   # Don't exit if -i flag was given.
    else:
        code = e.code
        if isinstance(code, int):
            exitcode = code
        else:
            f = getattr(sys, 'stderr', None)
            if f is None:
                f = sys.__stderr__
            print >> f, code
            exitcode = 1

        _rawffi.exit(exitcode)