Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1ec7a69
std: Add an unstable method Child::id
alexcrichton Apr 16, 2015
1254c34
Add example for from_str_radix
steveklabnik May 18, 2015
733e7ee
fmt.rs: add note about lack of padding support for some types
parkr May 19, 2015
aa570bc
Fix lifetimes trpl typo
cipherself May 19, 2015
afbe15d
Fix description of assert!
peferron May 18, 2015
c9c474c
doc: add missing fences
parir May 19, 2015
3b95cd7
doc: fix a broken link
parir May 19, 2015
01c93a5
mk: Report the prerelease version on beta again. Fixes #25618
brson May 19, 2015
f34ff7a
Auto merge of #25495 - alexcrichton:process-pid, r=aturon
bors May 19, 2015
07c25d4
Rollup merge of #25583 - steveklabnik:gh25517, r=alexcrichton
steveklabnik May 19, 2015
1bcfe5e
Rollup merge of #25585 - sferik:change-default-gender, r=steveklabnik
steveklabnik May 19, 2015
6fc93b8
Rollup merge of #25602 - parkr:patch-1, r=alexcrichton
steveklabnik May 19, 2015
1d961fd
Rollup merge of #25604 - skeuomorf:docs-lifetime, r=steveklabnik
steveklabnik May 19, 2015
7f74212
Rollup merge of #25607 - peferron:doc-macros-assert-fix, r=steveklabnik
steveklabnik May 19, 2015
dd1c68e
Rollup merge of #25611 - parir:patch-1, r=steveklabnik
steveklabnik May 19, 2015
51a0c6a
Rollup merge of #25614 - parir:patch-2, r=alexcrichton
steveklabnik May 19, 2015
ed3c644
Rollup merge of #25620 - brson:betavers, r=alexcrichton
steveklabnik May 19, 2015
55da4c6
Small fix for https://github.com/rust-lang/rust/pull/25611
steveklabnik May 20, 2015
395d01c
Fix for https://github.com/rust-lang/rust/pull/25583
steveklabnik May 20, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libstd/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ impl Child {
unsafe { self.handle.kill() }
}

/// Returns the OS-assigned process identifier associated with this child.
#[unstable(feature = "process_id", reason = "api recently added")]
pub fn id(&self) -> u32 {
self.handle.id()
}

/// Waits for the child to exit completely, returning the status that it
/// exited with. This function will continue to have the same return value
/// after it has been called at least once.
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/sys/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ impl Process {
fail(&mut output)
}

pub fn id(&self) -> u32 {
self.pid as u32
}

pub fn wait(&self) -> io::Result<ExitStatus> {
let mut status = 0 as c_int;
try!(cvt_r(|| unsafe { c::waitpid(self.pid, &mut status, 0) }));
Expand Down
1 change: 1 addition & 0 deletions src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ extern "system" {
dwMilliseconds: libc::DWORD) -> libc::DWORD;
pub fn SwitchToThread() -> libc::BOOL;
pub fn Sleep(dwMilliseconds: libc::DWORD);
pub fn GetProcessId(handle: libc::HANDLE) -> libc::DWORD;
}

#[link(name = "userenv")]
Expand Down
6 changes: 6 additions & 0 deletions src/libstd/sys/windows/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ impl Process {
Ok(())
}

pub fn id(&self) -> u32 {
unsafe {
c::GetProcessId(self.handle.raw()) as u32
}
}

pub fn wait(&self) -> io::Result<ExitStatus> {
use libc::{STILL_ACTIVE, INFINITE, WAIT_OBJECT_0};
use libc::{GetExitCodeProcess, WaitForSingleObject};
Expand Down