Skip to content

Commit 37e0c10

Browse files
bors[bot]Mandragorianasomers
authored
Merge #1448
1448: Add documentation for sched::clone r=asomers a=Mandragorian 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. Co-authored-by: Konstantinos Andrikopoulos <mandragore@protonmail.com> Co-authored-by: Alan Somers <asomers@gmail.com>
2 parents 99fc58e + 9f71a49 commit 37e0c10

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/sched.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ 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. Unlike when calling `clone(2)` from C, the provided stack
184+
/// address need not be the highest address of the region. Nix will take
185+
/// care of that requirement. The user only needs to provide a reference to
186+
/// a normally allocated buffer.
179187
pub fn clone(
180188
mut cb: CloneCb,
181189
stack: &mut [u8],

0 commit comments

Comments
 (0)