summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Andrikopoulos <mandragore@protonmail.com>2021-06-12 17:32:36 +0200
committerKonstantinos Andrikopoulos <mandragore@protonmail.com>2021-06-12 17:32:36 +0200
commit4402a02f14cf647341b8616ba060c9dfa66561e1 (patch)
tree49dfc50d0fc6e1831191a450370842fa38e5f5c7 /src
parent99fc58e9bd14a30d8b5eb84b979679c13138b06c (diff)
downloadnix-4402a02f14cf647341b8616ba060c9dfa66561e1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/sched.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sched.rs b/src/sched.rs
index 576eb4aa..f851618a 100644
--- a/src/sched.rs
+++ b/src/sched.rs
@@ -176,6 +176,15 @@ mod sched_linux_like {
Errno::result(res).and(Ok(cpuset))
}
+ /// `clone` create a child process
+ /// ([`clone(2)`](https://man7.org/linux/man-pages/man2/clone.2.html))
+ ///
+ /// `stack` is a reference to an array which will hold the stack of the new
+ /// process. Contrary to colling `clone(2)` from C, where the provided
+ /// stack address must be the highest address of the memory region, this is
+ /// not needed here. This requirement will be taken care of by `nix` and
+ /// the user only needs to provide a reference to a normally allocated
+ /// buffer.
pub fn clone(
mut cb: CloneCb,
stack: &mut [u8],