STRUCT CLONE_ARGS(9)
π¦ struct clone_args(9) β the kernel API manual, bestie edition π¦
okay so this is the struct clone_args(9) page from the Kernel API Manual, and it's literally the glow-up era of process creation. no cap, if you've ever poked at clone3 and been like "wait what do I even pass in here", this is your girl. π
β¨ NAME β¨
struct clone_args β the arguments for the clone3 syscall. that's it, that's the whole vibe. it's the little struct that tells the kernel exactly how you want your shiny new process built. π«Ά
β¨ SYNOPSIS β¨
struct clone_args {
__aligned_u64 flags;
__aligned_u64 pidfd;
__aligned_u64 child_tid;
__aligned_u64 parent_tid;
__aligned_u64 exit_signal;
__aligned_u64 stack;
__aligned_u64 stack_size;
__aligned_u64 tls;
__aligned_u64 set_tid;
__aligned_u64 set_tid_size;
__aligned_u64 cgroup;
};
look at her. every single field is __aligned_u64, she's uniform, she's consistent, she ate. π
πΈ Members πΈ
time for the roll call, one field at a time, no skipping, we don't do that here π
flagsβ the flags for the new process as listed above. all flags are valid except forCSIGNALandCLONE_DETACHED. like, those two specifically are not invited to the party π«pidfdβ ifCLONE_PIDFDis set, a pidfd gets returned in this argument. cute little handle for your new baby process πchild_tidβ ifCLONE_CHILD_SETTIDis set, the TID of the child process will be returned in the child's memory. it's giving "note to self" πparent_tidβ ifCLONE_PARENT_SETTIDis set, the TID of the child process will be returned in the parent's memory. so the parent gets the receipts too, love that for them π«Άexit_signalβ theexit_signalthe parent process will be sent when the child exits. yes it happens when the child exits, not if, we all exit eventually, main character energy πstackβ specify the location of the stack for the child process. heads up bestie:stackis expected to point to the lowest address. the stack direction will be determined by the kernel and set up appropriately based onstack_size. so don't go assuming which way it grows, the kernel decides, you just hand over the address πstack_sizeβ the size of the stack for the child process. that's it. that's the field πtlsβ ifCLONE_SETTLSis set, the tls descriptor is set totls. short, sweet, iconic β¨set_tidβ a pointer to an array of type*pid_t. the size of the array is defined usingset_tid_size. this array is used to select PIDs/TIDs for newly created processes. the first element in this defines the PID in the most nested PID namespace. each additional element in the array defines the PID in the parent PID namespace of the original PID namespace. and if the array has less entries than the number of currently nested PID namespaces, only the PIDs in the corresponding namespaces are set. so like, you don't have to fill the whole thing, the ones you do fill get used, lowkey flexible of her πset_tid_sizeβ this defines the size of the array referenced inset_tid. this cannot be larger than the kernel's limit of nested PID namespaces. do not try it. the kernel said no π«πcgroupβ ifCLONE_INTO_CGROUPis specified, set this to a file descriptor for the cgroup. drop your new process straight into its cgroup like it's sliding into the group chat π
π Description π
the structure is versioned by size and thus extensible β she grows, she evolves, she's not locked in π₯
new struct members must go at the end of the struct and must be properly 64bit aligned. that's the rule, that's the whole rule, periodt. no sneaking fields in the middle, no cap π§
π SEE ALSO π
- Kernel file
./tools/perf/trace/beauty/include/uapi/linux/sched.hβ go read the source, it's good for you π
and that's the page!! you made it to the end, so proud of you π₯Ή this little slice of the Kernel API Manual came to you from ./tools/perf/trace/beauty/incl... and is dated October 2026 β so go forth, build processes, and remember: correct alignment is self care. π
β¨π¦π
π¦ 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