diff options
| author | Theodore DeRego <tedsta@google.com> | 2016-11-30 14:20:44 -0800 |
|---|---|---|
| committer | Theodore DeRego <tedsta@google.com> | 2016-11-30 14:20:44 -0800 |
| commit | 8d9d07a1ca25d003b57b08f5930ae3e9a27cd37c (patch) | |
| tree | 5deda16d5b8698cdb4eb97d0bf18ed84db72aeb5 /src/libstd/sys/unix/magenta.rs | |
| parent | 5c1c48532f1f5ce726d1704d33366f8fb371cca0 (diff) | |
| download | rust-8d9d07a1ca25d003b57b08f5930ae3e9a27cd37c.tar.gz rust-8d9d07a1ca25d003b57b08f5930ae3e9a27cd37c.zip | |
Removed Option<ExitStatus> member from fuchsia Process struct. Destroy launchpads and close handles in Drop impls rather than manually
Diffstat (limited to 'src/libstd/sys/unix/magenta.rs')
| -rw-r--r-- | src/libstd/sys/unix/magenta.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/magenta.rs b/src/libstd/sys/unix/magenta.rs index 155259d2645..20e077ccaca 100644 --- a/src/libstd/sys/unix/magenta.rs +++ b/src/libstd/sys/unix/magenta.rs @@ -42,6 +42,30 @@ pub const MX_INFO_PROCESS : mx_object_info_topic_t = 3; pub const MX_HND_TYPE_JOB: u32 = 6; +// Safe wrapper around mx_handle_t +pub struct Handle { + raw: mx_handle_t, +} + +impl Handle { + pub fn new(raw: mx_handle_t) -> Handle { + Handle { + raw: raw, + } + } + + pub fn raw(&self) -> mx_handle_t { + self.raw + } +} + +impl Drop for Handle { + fn drop(&mut self) { + use sys::mx_cvt; + unsafe { mx_cvt(mx_handle_close(self.raw)).expect("Failed to close mx_handle_t"); } + } +} + // Common MX_INFO header #[derive(Default)] #[repr(C)] @@ -68,6 +92,8 @@ pub struct mx_info_process_t { } extern { + pub fn mx_task_kill(handle: mx_handle_t) -> mx_status_t; + pub fn mx_handle_close(handle: mx_handle_t) -> mx_status_t; pub fn mx_handle_duplicate(handle: mx_handle_t, rights: mx_rights_t, |
