File tree Expand file tree Collapse file tree 6 files changed +22
-9
lines changed Expand file tree Collapse file tree 6 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: b748c2e90d87985fbff1d99e17d94a10cf2b3f21
2
+ refs/heads/master: 1bcfe5e5ad61e23475dd980288516db6e994bcdc
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 857ef6e272e5634cb9f3e6ee50eb6bc2a2e71651
5
5
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
Original file line number Diff line number Diff line change @@ -132,15 +132,11 @@ macro_rules! int_impl {
132
132
///
133
133
/// Leading and trailing whitespace represent an error.
134
134
///
135
- /// # Arguments
136
- ///
137
- /// * src - A string slice
138
- /// * radix - The base to use. Must lie in the range [2 .. 36]
139
- ///
140
- /// # Return value
135
+ /// # Examples
141
136
///
142
- /// `Err(ParseIntError)` if the string did not represent a valid number.
143
- /// Otherwise, `Ok(n)` where `n` is the integer represented by `src`.
137
+ /// ```
138
+ /// assert_eq!(u32::from_str_radix("A", 16), Some(10));
139
+ /// ```
144
140
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
145
141
#[ allow( deprecated) ]
146
142
pub fn from_str_radix( src: & str , radix: u32 ) -> Result <$T, ParseIntError > {
Original file line number Diff line number Diff line change @@ -456,6 +456,12 @@ impl Child {
456
456
unsafe { self . handle . kill ( ) }
457
457
}
458
458
459
+ /// Returns the OS-assigned process identifier associated with this child.
460
+ #[ unstable( feature = "process_id" , reason = "api recently added" ) ]
461
+ pub fn id ( & self ) -> u32 {
462
+ self . handle . id ( )
463
+ }
464
+
459
465
/// Waits for the child to exit completely, returning the status that it
460
466
/// exited with. This function will continue to have the same return value
461
467
/// after it has been called at least once.
Original file line number Diff line number Diff line change @@ -315,6 +315,10 @@ impl Process {
315
315
fail ( & mut output)
316
316
}
317
317
318
+ pub fn id ( & self ) -> u32 {
319
+ self . pid as u32
320
+ }
321
+
318
322
pub fn wait ( & self ) -> io:: Result < ExitStatus > {
319
323
let mut status = 0 as c_int ;
320
324
try!( cvt_r ( || unsafe { c:: waitpid ( self . pid , & mut status, 0 ) } ) ) ;
Original file line number Diff line number Diff line change @@ -482,6 +482,7 @@ extern "system" {
482
482
dwMilliseconds : libc:: DWORD ) -> libc:: DWORD ;
483
483
pub fn SwitchToThread ( ) -> libc:: BOOL ;
484
484
pub fn Sleep ( dwMilliseconds : libc:: DWORD ) ;
485
+ pub fn GetProcessId ( handle : libc:: HANDLE ) -> libc:: DWORD ;
485
486
}
486
487
487
488
#[ link( name = "userenv" ) ]
Original file line number Diff line number Diff line change @@ -193,6 +193,12 @@ impl Process {
193
193
Ok ( ( ) )
194
194
}
195
195
196
+ pub fn id ( & self ) -> u32 {
197
+ unsafe {
198
+ c:: GetProcessId ( self . handle . raw ( ) ) as u32
199
+ }
200
+ }
201
+
196
202
pub fn wait ( & self ) -> io:: Result < ExitStatus > {
197
203
use libc:: { STILL_ACTIVE , INFINITE , WAIT_OBJECT_0 } ;
198
204
use libc:: { GetExitCodeProcess , WaitForSingleObject } ;
You can’t perform that action at this time.
0 commit comments