Skip to content

Commit b06432b

Browse files
committed
Allow to specify signal when calling clone.
1 parent fc764da commit b06432b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sched.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::mem;
22
use std::os::unix::io::RawFd;
3+
use std::option::Option;
34
use libc::{self, c_int, c_void, c_ulong, pid_t};
45
use {Errno, Result};
56

@@ -197,17 +198,18 @@ pub fn sched_setaffinity(pid: isize, cpuset: &CpuSet) -> Result<()> {
197198
Errno::result(res).map(drop)
198199
}
199200

200-
pub fn clone(mut cb: CloneCb, stack: &mut [u8], flags: CloneFlags) -> Result<pid_t> {
201+
pub fn clone(mut cb: CloneCb, stack: &mut [u8], flags: CloneFlags, signal: Option<c_int>) -> Result<pid_t> {
201202
extern "C" fn callback(data: *mut CloneCb) -> c_int {
202203
let cb: &mut CloneCb = unsafe { &mut *data };
203204
(*cb)() as c_int
204205
}
205206

206207
let res = unsafe {
208+
let combined = flags.bits() | signal.unwrap_or(0);
207209
let ptr = stack.as_mut_ptr().offset(stack.len() as isize);
208210
ffi::clone(mem::transmute(callback as extern "C" fn(*mut Box<::std::ops::FnMut() -> isize>) -> i32),
209211
ptr as *mut c_void,
210-
flags.bits(),
212+
combined,
211213
&mut cb)
212214
};
213215

0 commit comments

Comments
 (0)