sys_clone3(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 the struct clone_args __user *, and it's where all the "specific properties" actually live. her little info packet πŸ’Œ
  • size β€” size of uargs. 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 errno number πŸ’€ 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:

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_clone3 is a sys_-prefixed internal helper, not the userspace clone3(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