Skip to content

Commit 4402a02

Browse files
committed
Add documentation for sched::clone
Add a note in the documentation for sched::clone to point out that the stack pointer does not neet to be a reference to the highest address of the stack. Users who simply read the manpages for clone(2) might assume that they will need to use unsafe pointer arithmetics in order to create a reference to the highest address of their buffer, rather than providing their buffer directly.
1 parent 99fc58e commit 4402a02

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/sched.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,15 @@ mod sched_linux_like {
176176
Errno::result(res).and(Ok(cpuset))
177177
}
178178

179+
/// `clone` create a child process
180+
/// ([`clone(2)`](https://man7.org/linux/man-pages/man2/clone.2.html))
181+
///
182+
/// `stack` is a reference to an array which will hold the stack of the new
183+
/// process. Contrary to colling `clone(2)` from C, where the provided
184+
/// stack address must be the highest address of the memory region, this is
185+
/// not needed here. This requirement will be taken care of by `nix` and
186+
/// the user only needs to provide a reference to a normally allocated
187+
/// buffer.
179188
pub fn clone(
180189
mut cb: CloneCb,
181190
stack: &mut [u8],

0 commit comments

Comments
 (0)