kthread_complete_and_exit(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ kthread_complete_and_exit(9) ✨

Okay bestie, so this one is a Linux kernel API manual page β€” kthread_complete_and_exit(9) β€” and honestly it's short, it's sweet, and it does not come back. Let's get into it 🫢


🌸 NAME 🌸

kthread_complete_and_exit β€” exit the current kthread. That's it, that's the whole job. Main character energy: arrives, completes a thing, leaves forever πŸ’…


✨ SYNOPSIS ✨

void __noreturn kthread_complete_and_exit (struct completion *comp ,
long code );

Note the __noreturn bestie β€” that is not a decoration, that is a promise πŸ”₯


πŸŽ€ ARGUMENTS πŸŽ€

  • comp β€” the completion you want to complete. Yep. It completes a completion. Iconic, no notes πŸ’–
  • code β€” the integer value that gets returned to kthread_stop.

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the vibe: if comp is present, this function completes comp, and then it returns code to kthread_stop. Simple. Clean. Slay ✨

Now the actually-important part πŸ‘‘ β€” a kernel thread whose module could get removed after the completion of comp can use this function to exit safely. That's the whole reason it exists, and it's lowkey genius.

Does not return. Like, at all. Ever. Fr fr β€” this one is __noreturn, so do not go writing code after the call expecting to come back. It's giving exit-stage-left, not exit-stage-then-do-more-stuff πŸ’€

🌈 SEE ALSO 🌈

Kernel file ./kernel/kthread.c, plus the whole kthread friend group β€” honestly a whole group chat, and they're all here:


And that's the page, bestie! πŸŽ€ Signed off from the ./kernel section, dated October 2026 β€” the kernel kthread girlies really said "we'll document it and we'll do it cutely" πŸ’œβœ¨

πŸ“¦ where this page comes from