diff options
author | Martin Habovštiak <martin.habovstiak@gmail.com> | 2017-06-24 10:05:03 +0200 |
---|---|---|
committer | Martin Habovštiak <martin.habovstiak@gmail.com> | 2017-07-02 08:09:25 +0200 |
commit | b62ab099c8aa3ae59a9298fee342cd316f14a8b1 (patch) | |
tree | 42f0b59426ef6c368b8c1a9f19dce51e0353ea0a /src/sched.rs | |
parent | 274b09eee1cdac51ceea9238d2e584babae48720 (diff) | |
download | nix-b62ab099c8aa3ae59a9298fee342cd316f14a8b1.zip |
Newtypes for uid_t, gid_t and pid_t.
Diffstat (limited to 'src/sched.rs')
-rw-r--r-- | src/sched.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/sched.rs b/src/sched.rs index eefd29b2..0b98c580 100644 --- a/src/sched.rs +++ b/src/sched.rs @@ -1,8 +1,9 @@ use std::mem; use std::os::unix::io::RawFd; use std::option::Option; -use libc::{self, c_int, c_void, pid_t}; +use libc::{self, c_int, c_void}; use {Errno, Error, Result}; +use ::unistd::Pid; // For some functions taking with a parameter of type CloneFlags, // only a subset of these flags have an effect. @@ -91,9 +92,9 @@ mod ffi { } } -pub fn sched_setaffinity(pid: pid_t, cpuset: &CpuSet) -> Result<()> { +pub fn sched_setaffinity(pid: Pid, cpuset: &CpuSet) -> Result<()> { let res = unsafe { - libc::sched_setaffinity(pid, + libc::sched_setaffinity(pid.into(), mem::size_of::<CpuSet>() as libc::size_t, mem::transmute(cpuset)) }; @@ -105,7 +106,7 @@ pub fn clone(mut cb: CloneCb, stack: &mut [u8], flags: CloneFlags, signal: Option<c_int>) - -> Result<pid_t> { + -> Result<Pid> { extern "C" fn callback(data: *mut CloneCb) -> c_int { let cb: &mut CloneCb = unsafe { &mut *data }; (*cb)() as c_int @@ -121,7 +122,7 @@ pub fn clone(mut cb: CloneCb, &mut cb) }; - Errno::result(res) + Errno::result(res).map(Pid::from_raw) } pub fn unshare(flags: CloneFlags) -> Result<()> { |