sys_clone3(9)
π sys_clone3 β the Kernel API Manual, bestie edition π
okay so we're in the Kernel API Manual today and the star of the show is sys_clone3(9). yes it's a kernel-internal thing, no you cannot just call it from your little userspace script, but we're learning it anyway because it's iconic and i said so π
β¨ NAME β¨
sys_clone3 β create a new process with specific properties
like, a whole new process. with specific properties. she's customizable, she's extensible, she's everything π
πΈ SYNOPSIS πΈ
long sys_clone3 (struct clone_args __user * uargs , size_t size );
that's it. that's the whole signature. two args, one return value, zero drama (mostly) π¦
π ARGUMENTS π
uargsβ the argument structure. it's thestruct clone_args __user *, and it's where all the "specific properties" actually live. her little info packet πsizeβ size ofuargs. literally how big that struct is. it's not just a formality, she uses it (see description, it's important, i promise) β
π₯ DESCRIPTION π₯
okay so here's the tea β β clone3 is the extensible successor to clone/clone2. think of clone and clone2 as the older siblings who did their best, and clone3 as the youngest who showed up with a whole new architecture and main character energy π
the way she works: she takes a struct as argument that is versioned by its size. meaning the size field isn't just a random number, it's literally how she knows which version of the struct you're handing her. so if you pass the wrong size... yeah. don't do that. it's giving "undefined vibes" and not in the fun way π
the whole point of this design is extensibility, no cap β as the struct grows in future versions, old callers keep working because they declare the size they know about. it's forward-compatible and backward-compatible. she ate and left no crumbs π
β RETURN β
- On success β a positive PID for the child process π like, the baby process is alive and here's her ID, go say hi
- On error β a negative
errnonumber π so if you get something less than zero, that's your sign that things went sideways, and the value tells you how
ngl the negative-errno thing trips people up constantly. it's not "minus one means something cool", it's literally the errno value, negated. read it, diagnose it, move on π«Ά
π SEE ALSO π
she doesn't exist in a vacuum, bestie β here's the whole friend group, all from the Kernel file ./kernel/fork.c:
set_mm_exe_file(9)replace_mm_exe_file(9)get_mm_exe_file(9)get_task_exe_file(9)get_task_mm(9)dup_mm(9)pidfd_prepare(9)clone3_stack_valid(9)
like, clone3_stack_valid(9) alone is worth a read β she's the vibe check for the stack, iykyk π§
π friendly reminder: this is a kernel API page.sys_clone3is asys_-prefixed internal helper, not the userspaceclone3(2)wrapper you'd actually call. don't go pasting this into your C file and wondering why it doesn't link, i'm begging π
so yeah, that's sys_clone3(9) β extensible, versioned by size, returns a positive PID on success and a negative errno on error, and honestly? obsessed π¦β¨
this lil page lives at ./kernel in the source tree, from October 2026, π and that's the whole manual, periodt π
π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms