@@ -19,7 +19,7 @@ use std::{
1919 pin:: Pin ,
2020 process:: ExitStatus ,
2121 sync:: atomic:: { AtomicBool , Ordering :: Relaxed } ,
22- task:: { ready , Context , Poll } ,
22+ task:: { Context , Poll } ,
2323} ;
2424
2525#[ derive( Debug ) ]
@@ -117,17 +117,21 @@ where
117117 fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
118118 let this = Pin :: into_inner ( self ) ;
119119
120- match ready ! ( this. pidfd. poll_read_ready( cx) ) {
121- Err ( err) if is_rt_shutdown_err ( & err) => {
122- this. pidfd . reregister ( Interest :: READABLE ) ?;
123- ready ! ( this. pidfd. poll_read_ready( cx) ) ?
120+ match this. pidfd . registration ( ) . poll_read_ready ( cx) {
121+ Poll :: Ready ( Ok ( evt) ) => {
122+ if let Some ( exit_code) = this. inner . try_wait ( ) ? {
123+ return Poll :: Ready ( Ok ( exit_code) ) ;
124+ }
125+ this. pidfd . registration ( ) . clear_readiness ( evt) ;
124126 }
125- res => res?,
126- }
127- Poll :: Ready ( Ok ( this
128- . inner
129- . try_wait ( ) ?
130- . expect ( "pidfd is ready to read, the process should have exited" ) ) )
127+ Poll :: Ready ( Err ( err) ) if is_rt_shutdown_err ( & err) => { }
128+ Poll :: Ready ( Err ( err) ) => return Poll :: Ready ( Err ( err) ) ,
129+ Poll :: Pending => return Poll :: Pending ,
130+ } ;
131+
132+ this. pidfd . reregister ( Interest :: READABLE ) ?;
133+ cx. waker ( ) . wake_by_ref ( ) ;
134+ Poll :: Pending
131135 }
132136}
133137
0 commit comments