Пример #1
0
    def test_09_event_exit(self):
        pid = os.fork()
        if not pid: # child
            trace.me()
            os.kill(os.getpid(), signal.SIGSTOP)

            os._exit(13)
        else: # parent
            os.waitpid(pid, 0)
            trace.setup(pid, trace.OPTION_SYSGOOD | trace.OPTION_EXIT)

            trace.cont(pid)
            pid, status = os.waitpid(pid, 0)
            ev = event.decide(status)
            self.assertEqual(ev, event.EVENT_EXIT)
            msg = trace.geteventmsg(pid)
            self.assertEqual(os.WEXITSTATUS(msg), 13)

            try: trace.kill(pid)
            except OSError: pass
Пример #2
0
    def test_04_event_fork(self):
        pid = os.fork()
        if not pid: # child
            trace.me()
            os.kill(os.getpid(), signal.SIGSTOP)

            os.fork()
            os._exit(0)
        else: # parent
            os.waitpid(pid, 0)
            trace.setup(pid, trace.OPTION_SYSGOOD | trace.OPTION_FORK)

            trace.cont(pid)
            pid, status = os.waitpid(pid, 0)
            ev = event.decide(status)
            self.assertEqual(ev, event.EVENT_FORK)

            try:
                child = trace.geteventmsg(pid)
                trace.kill(child)
                trace.kill(pid)
            except OSError: pass
Пример #3
0
    def test_09_event_exit(self):
        pid = os.fork()
        if not pid:  # child
            trace.me()
            os.kill(os.getpid(), signal.SIGSTOP)

            os._exit(13)
        else:  # parent
            os.waitpid(pid, 0)
            trace.setup(pid, trace.OPTION_SYSGOOD | trace.OPTION_EXIT)

            trace.cont(pid)
            pid, status = os.waitpid(pid, 0)
            ev = event.decide(status)
            self.assertEqual(ev, event.EVENT_EXIT)
            msg = trace.geteventmsg(pid)
            self.assertEqual(os.WEXITSTATUS(msg), 13)

            try:
                trace.kill(pid)
            except OSError:
                pass
Пример #4
0
    def test_04_event_fork(self):
        pid = os.fork()
        if not pid:  # child
            trace.me()
            os.kill(os.getpid(), signal.SIGSTOP)

            os.fork()
            os._exit(0)
        else:  # parent
            os.waitpid(pid, 0)
            trace.setup(pid, trace.OPTION_SYSGOOD | trace.OPTION_FORK)

            trace.cont(pid)
            pid, status = os.waitpid(pid, 0)
            ev = event.decide(status)
            self.assertEqual(ev, event.EVENT_FORK)

            try:
                child = trace.geteventmsg(pid)
                trace.kill(child)
                trace.kill(pid)
            except OSError:
                pass