Ϫf dZddlmZddlZddlZddlZddlmZddlm Z edk(rddl m Z m Z ddl mZnd ZGd d e Zy) zX Tests for L{twisted.internet._sigchld}, an alternate, superior SIGCHLD monitoring API. ) annotationsN) platformType)SynchronousTestCaseposix)installHandlerisDefaultHandler)setNonBlockingz,These tests can only run on POSIX platforms.cHeZdZdZd dZd dZd dZd dZd dZd dZ d dZ y ) SetWakeupSIGCHLDTestszy Tests for the L{signal.set_wakeup_fd} implementation of the L{installHandler} and L{isDefaultHandler} APIs. ctj\}}|jtj||jtj|t |t |||fS)zk Create a non-blocking pipe which will be closed after the currently running test. )ospipe addCleanupcloser selfreadwrites D/usr/lib/python3/dist-packages/twisted/internet/test/test_sigchld.pyrzSetWakeupSIGCHLDTests.pipesQ ggi e $' %(tuU{cttjtj|_t d|_y)z Save the current SIGCHLD handler as reported by L{signal.signal} and the current file descriptor registered with L{installHandler}. N)signal getsignalSIGCHLDsignalModuleHandlerroldFDrs rsetUpzSetWakeupSIGCHLDTests.setUp*s' $*#3#3FNN#C #B' rct|jtjtj|jy)zM Restore whatever signal handler was present when setUp ran. N)rrrrrrs rtearDownzSetWakeupSIGCHLDTests.tearDown2s( tzz" fnnd&>&>?rc|jttjtjtj|j ttjtjtj |jttjtjd|j ty)zn L{isDefaultHandler} returns true if the SIGCHLD handler is SIG_DFL, false otherwise. cy)N)argss rz=SetWakeupSIGCHLDTests.test_isDefaultHandler..DsrN) assertTruerrrSIG_IGN assertFalseSIG_DFLrs rtest_isDefaultHandlerz+SetWakeupSIGCHLDTests.test_isDefaultHandler:s (*+ fnnfnn5 )+, fnnfnn5 (*+ fnn&89 )+,rcv|j\}}t|}|jt||y)zV L{installHandler} returns the previously registered file descriptor. N)rr assertEqual)rrrrs rtest_returnOldFDz&SetWakeupSIGCHLDTests.test_returnOldFDGs2iik eu% .6rc|j\}}|jtt||j ttd|jty)zO C{installHandler(-1)} removes the SIGCHLD handler completely. rN)rr'rrr)rs rtest_uninstallHandlerz+SetWakeupSIGCHLDTests.test_uninstallHandlerOsUiik e (*+u )+,r (*+rc|j\}}t||jttj |d}|j |jtjt jt jtj|j tt j |ddy)z The file descriptor passed to L{installHandler} has a byte written to it when SIGCHLD is delivered to the process. N)rr assertRaisesOSErrorr rr-errnoEAGAINkillgetpidrrlen)rrrexcs rtest_installHandlerz)SetWakeupSIGCHLDTests.test_installHandlerZs iik eu$: ELL1  V^^, RWWT1-.2rN)returnztuple[int, int])r=None) __name__ __module__ __qualname____doc__rrr!r+r.r0r<r$rrr r s+ (@ -7 , 3rr )rB __future__rr6r rtwisted.python.runtimertwisted.trial.unittestrtwisted.internet._signalsrrtwisted.internet.fdescr skipr r$rrrIs@# /67J5 9DO3/O3r