@@ -10,7 +10,7 @@ use std::convert::TryFrom;
10
10
target_os = "android" ,
11
11
all( target_os = "linux" , not( target_env = "uclibc" ) ) ,
12
12
) ) ]
13
- use std:: os:: unix:: io:: RawFd ;
13
+ use std:: os:: unix:: io:: { AsRawFd , BorrowedFd } ;
14
14
15
15
libc_bitflags ! (
16
16
/// Controls the behavior of [`waitpid`].
@@ -343,8 +343,8 @@ pub fn wait() -> Result<WaitStatus> {
343
343
target_os = "haiku" ,
344
344
all( target_os = "linux" , not( target_env = "uclibc" ) ) ,
345
345
) ) ]
346
- #[ derive( Debug , Clone , Copy , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
347
- pub enum Id {
346
+ #[ derive( Debug ) ]
347
+ pub enum Id < ' fd > {
348
348
/// Wait for any child
349
349
All ,
350
350
/// Wait for the child whose process ID matches the given PID
@@ -355,7 +355,11 @@ pub enum Id {
355
355
PGid ( Pid ) ,
356
356
/// Wait for the child referred to by the given PID file descriptor
357
357
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
358
- PIDFd ( RawFd ) ,
358
+ PIDFd ( BorrowedFd < ' fd > ) ,
359
+ /// A helper variant to resolve the unused parameter (`'fd`) problem on platforms
360
+ /// other than Linux and Android.
361
+ #[ doc( hidden) ]
362
+ _Unreachable( std:: marker:: PhantomData < & ' fd std:: convert:: Infallible > ) ,
359
363
}
360
364
361
365
/// Wait for a process to change status
@@ -373,7 +377,8 @@ pub fn waitid(id: Id, flags: WaitPidFlag) -> Result<WaitStatus> {
373
377
Id :: Pid ( pid) => ( libc:: P_PID , pid. as_raw ( ) as libc:: id_t ) ,
374
378
Id :: PGid ( pid) => ( libc:: P_PGID , pid. as_raw ( ) as libc:: id_t ) ,
375
379
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
376
- Id :: PIDFd ( fd) => ( libc:: P_PIDFD , fd as libc:: id_t ) ,
380
+ Id :: PIDFd ( fd) => ( libc:: P_PIDFD , fd. as_raw_fd ( ) as libc:: id_t ) ,
381
+ Id :: _Unreachable( _) => unreachable ! ( "This variant could never be constructed" ) ,
377
382
} ;
378
383
379
384
let siginfo = unsafe {
0 commit comments