#linux #syscalls #clone

clone3

Rust bindings to the clone3 linux system call

5 releases

0.2.3 Dec 7, 2022
0.2.2 Jul 8, 2022
0.2.1 Jul 7, 2022
0.2.0 Jan 12, 2021
0.1.0 Jan 10, 2021

#488 in Unix APIs

Download history 976/week @ 2024-07-20 1159/week @ 2024-07-27 779/week @ 2024-08-03 1058/week @ 2024-08-10 1002/week @ 2024-08-17 1395/week @ 2024-08-24 1156/week @ 2024-08-31 1815/week @ 2024-09-07 1904/week @ 2024-09-14 1990/week @ 2024-09-21 4145/week @ 2024-09-28 5950/week @ 2024-10-05 3103/week @ 2024-10-12 3831/week @ 2024-10-19 4377/week @ 2024-10-26 3734/week @ 2024-11-02

16,206 downloads per month
Used in intentrace

MIT license

17KB
348 lines

crates.io, docs.rs

clone3

Rust bindings to the clone3 linux system call.

Development

Currently the bindings we provide are unsafe. We could look into making a safe wrapper on a restricted subset of the api.


lib.rs:

Bindings to the clone3 linux system call.

See the clone3 man page for more information.

This is a complex and generally unsafe operation. Users must understand the documentation to use it safely and correctly.

Examples

use clone3::Clone3;

let mut pidfd = -1;
let mut clone3 = Clone3::default();
clone3.flag_pidfd(&mut pidfd);

match unsafe { clone3.call() }.unwrap() {
    0 => println!("i am the child"),
    child => println!("i am the parent, my child has pid {} and my pidfd is {}", child, pidfd),
}

Features

The clone3 api can change in a backward compatible manner between Linux kernel versions. This crate supports picking the target version through Cargo features like linux_5-5, linux_5-7. The default is the newest kernel version. Specifying no linux feature corresponds to the initial clone3 api.

Dependencies

~4.5–6.5MB
~120K SLoC