+
    Dfj                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ]R8X  d   ^ RI
HtHt ^ RIHt MRt ! R	 R
]	4      tR# )zX
Tests for L{twisted.internet._sigchld}, an alternate, superior SIGCHLD
monitoring API.
)annotationsN)platformType)SynchronousTestCaseposix)installHandlerisDefaultHandler)setNonBlockingz,These tests can only run on POSIX platforms.c                  n    ] tR t^tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltRtR# )SetWakeupSIGCHLDTestszm
Tests for the L{signal.set_wakeup_fd} implementation of the
L{installHandler} and L{isDefaultHandler} APIs.
c                   V ^8  d   QhRR/# )   returnztuple[int, int] )formats   "D/usr/lib/python3/dist-packages/twisted/internet/test/test_sigchld.py__annotate__"SetWakeupSIGCHLDTests.__annotate__   s     
 
o 
    c                    \         P                  ! 4       w  rV P                  \         P                  V4       V P                  \         P                  V4       \	        V4       \	        V4       W3# )zS
Create a non-blocking pipe which will be closed after the currently
running test.
)ospipe
addCleanupcloser   selfreadwrites   &  r   r   SetWakeupSIGCHLDTests.pipe   sM    
 ggi$'%(tu{r   c                   V ^8  d   QhRR/# r   r   Noner   )r   s   "r   r   r   *   s     ( (t (r   c                x    \         P                  ! \         P                  4      V n        \	        R4      V n        R# )z
Save the current SIGCHLD handler as reported by L{signal.signal} and
the current file descriptor registered with L{installHandler}.
N)signal	getsignalSIGCHLDsignalModuleHandlerr   oldFDr   s   &r   setUpSetWakeupSIGCHLDTests.setUp*   s'    
 $*#3#3FNN#C #B'
r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   2   s     @ @$ @r   c                    \        V P                  4       \        P                  ! \        P                  V P                  4       R# )z=
Restore whatever signal handler was present when setUp ran.
N)r   r'   r#   r%   r&   r(   s   &r   tearDownSetWakeupSIGCHLDTests.tearDown2   s(    
 	tzz"fnnd&>&>?r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   :   s     - -t -r   c                   V P                  \        4       4       \        P                  ! \        P                  \        P                  4       V P                  \        4       4       \        P                  ! \        P                  \        P                  4       V P                  \        4       4       \        P                  ! \        P                  R 4       V P                  \        4       4       R# )zV
L{isDefaultHandler} returns true if the SIGCHLD handler is SIG_DFL,
false otherwise.
c                     R # )Nr   )argss   *r   <lambda>=SetWakeupSIGCHLDTests.test_isDefaultHandler.<locals>.<lambda>D   s    Dr   N)
assertTruer   r#   r%   SIG_IGNassertFalseSIG_DFLr(   s   &r   test_isDefaultHandler+SetWakeupSIGCHLDTests.test_isDefaultHandler:   s    
 	(*+fnnfnn5)+,fnnfnn5(*+fnn&89)+,r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   G   s     7 7$ 7r   c                v    V P                  4       w  r\        V4      pV P                  \        V4      V4       R# )zF
L{installHandler} returns the previously registered file descriptor.
N)r   r   assertEqual)r   r   r   r'   s   &   r   test_returnOldFD&SetWakeupSIGCHLDTests.test_returnOldFDG   s0     iiku%.6r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   O   s     	, 	,t 	,r   c                    V P                  4       w  rV P                  \        4       4       \        V4       V P	                  \        4       4       \        R4       V P                  \        4       4       R# )z?
C{installHandler(-1)} removes the SIGCHLD handler completely.
Nr"   )r   r5   r   r   r7   r   s   &  r   test_uninstallHandler+SetWakeupSIGCHLDTests.test_uninstallHandlerO   sS     iik(*+u)+,r(*+r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r   Z   s     3 3T 3r   c                   V P                  4       w  r\        V4       V P                  \        \        P
                  V^4      pV P                  VP                  \        P                  4       \        P                  ! \        P                  ! 4       \        P                  4       V P                  \        \        P
                  ! V^4      4      ^4       R# )zt
The file descriptor passed to L{installHandler} has a byte written to
it when SIGCHLD is delivered to the process.
N)r   r   assertRaisesOSErrorr   r   r=   errnoEAGAINkillgetpidr#   r%   len)r   r   r   excs   &   r   test_installHandler)SetWakeupSIGCHLDTests.test_installHandlerZ   s    
 iiku$:ELL1
		V^^,RWWT1-.2r   )r'   r&   N)__name__
__module____qualname____firstlineno____doc__r   r)   r-   r9   r>   rB   rN   __static_attributes__r   r   r   r
   r
      s0    

(@-7	,3 3r   r
   )rT   
__future__r   rH   r   r#   twisted.python.runtimer   twisted.trial.unittestr   twisted.internet._signalsr   r   twisted.internet.fdescr   skipr
   r   r   r   <module>r\      s@    #  	  / 67J59DO3/ O3r   