def test_returnOldFD(self):
     """
     L{installHandler} returns the previously registered file descriptor.
     """
     read, write = self.pipe()
     oldFD = installHandler(write)
     self.assertEqual(installHandler(oldFD), write)
Esempio n. 2
0
 def test_returnOldFD(self):
     """
     L{installHandler} returns the previously registered file descriptor.
     """
     read, write = self.pipe()
     oldFD = installHandler(write)
     self.assertEqual(installHandler(oldFD), write)
 def test_uninstallHandler(self):
     """
     C{installHandler(-1)} removes the SIGCHLD handler completely.
     """
     read, write = self.pipe()
     self.assertTrue(isDefaultHandler())
     installHandler(write)
     self.assertFalse(isDefaultHandler())
     installHandler(-1)
     self.assertTrue(isDefaultHandler())
Esempio n. 4
0
 def test_uninstallHandler(self):
     """
     C{installHandler(-1)} removes the SIGCHLD handler completely.
     """
     read, write = self.pipe()
     self.assertTrue(isDefaultHandler())
     installHandler(write)
     self.assertFalse(isDefaultHandler())
     installHandler(-1)
     self.assertTrue(isDefaultHandler())
    def tearDown(self):
        """
        Restore whatever signal handler was present when setUp ran.
        """
        # If tests set up any kind of handlers, clear them out.
        installHandler(-1)
        signal.signal(signal.SIGCHLD, signal.SIG_DFL)

        # Now restore whatever the setup was before the test ran.
        if self.signalModuleHandler is not None:
            signal.signal(signal.SIGCHLD, self.signalModuleHandler)
        elif self.oldFD != -1:
            installHandler(self.oldFD)
Esempio n. 6
0
    def tearDown(self):
        """
        Restore whatever signal handler was present when setUp ran.
        """
        # If tests set up any kind of handlers, clear them out.
        installHandler(-1)
        signal.signal(signal.SIGCHLD, signal.SIG_DFL)

        # Now restore whatever the setup was before the test ran.
        if self.signalModuleHandler is not None:
            signal.signal(signal.SIGCHLD, self.signalModuleHandler)
        elif self.oldFD != -1:
            installHandler(self.oldFD)
    def test_installHandler(self):
        """
        The file descriptor passed to L{installHandler} has a byte written to
        it when SIGCHLD is delivered to the process.
        """
        read, write = self.pipe()
        installHandler(write)

        exc = self.assertRaises(OSError, os.read, read, 1)
        self.assertEqual(exc.errno, errno.EAGAIN)

        os.kill(os.getpid(), signal.SIGCHLD)

        self.assertEqual(len(os.read(read, 5)), 1)
Esempio n. 8
0
    def test_installHandler(self):
        """
        The file descriptor passed to L{installHandler} has a byte written to
        it when SIGCHLD is delivered to the process.
        """
        read, write = self.pipe()
        installHandler(write)

        exc = self.assertRaises(OSError, os.read, read, 1)
        self.assertEqual(exc.errno, errno.EAGAIN)

        os.kill(os.getpid(), signal.SIGCHLD)

        self.assertEqual(len(os.read(read, 5)), 1)
    def setUp(self):
        """
        Save the current SIGCHLD handler as reported by L{signal.signal} and
        the current file descriptor registered with L{installHandler}.
        """
        handler = signal.getsignal(signal.SIGCHLD)
        if handler != signal.SIG_DFL:
            self.signalModuleHandler = handler
            signal.signal(signal.SIGCHLD, signal.SIG_DFL)
        else:
            self.signalModuleHandler = None

        self.oldFD = installHandler(-1)

        if self.signalModuleHandler is not None and self.oldFD != -1:
            msg("Previous test didn't clean up after its SIGCHLD setup: %r %r"
                % (self.signalModuleHandler, self.oldFD))
Esempio n. 10
0
    def setUp(self):
        """
        Save the current SIGCHLD handler as reported by L{signal.signal} and
        the current file descriptor registered with L{installHandler}.
        """
        handler = signal.getsignal(signal.SIGCHLD)
        if handler != signal.SIG_DFL:
            self.signalModuleHandler = handler
            signal.signal(signal.SIGCHLD, signal.SIG_DFL)
        else:
            self.signalModuleHandler = None

        self.oldFD = installHandler(-1)

        if self.signalModuleHandler is not None and self.oldFD != -1:
            msg("SIGCHLD setup issue: %r %r" % (self.signalModuleHandler, self.oldFD))
            raise RuntimeError("You used some signal APIs wrong!  Try again.")
Esempio n. 11
0
    def setUp(self):
        """
        Save the current SIGCHLD handler as reported by L{signal.signal} and
        the current file descriptor registered with L{installHandler}.
        """
        handler = signal.getsignal(signal.SIGCHLD)
        if handler != signal.SIG_DFL:
            self.signalModuleHandler = handler
            signal.signal(signal.SIGCHLD, signal.SIG_DFL)
        else:
            self.signalModuleHandler = None

        self.oldFD = installHandler(-1)

        if self.signalModuleHandler is not None and self.oldFD != -1:
            msg("Previous test didn't clean up after its SIGCHLD setup: %r %r"
                % (self.signalModuleHandler, self.oldFD))
Esempio n. 12
0
 def uninstall(self):
     """
     Remove the handler which makes this waker active.
     """
     _signals.installHandler(-1)
Esempio n. 13
0
 def install(self):
     """
     Install the handler necessary to make this waker active.
     """
     _signals.installHandler(self.o)
Esempio n. 14
0
 def uninstall(self):
     """
     Remove the handler which makes this waker active.
     """
     _signals.installHandler(-1)
Esempio n. 15
0
 def install(self):
     """
     Install the handler necessary to make this waker active.
     """
     _signals.installHandler(self.o)