kthread_complete_and_exit(9)
β¨ 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 tokthread_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:
kthread_should_stop(9)kthread_should_park(9)kthread_freezable_should_stop(9)kthread_func(9)kthread_data(9)kthread_probe_data(9)kthread_create_on_node(9)kthread_bind(9)kthread_create_on_cpu(9)kthread_unpark(9)kthread_park(9)kthread_stop(9)kthread_stop_put(9)kthread_affine_preferred(9)kthreads_update_housekeeping(9)kthread_worker_fn(9)kthread_create_worker_on_node(9)kthread_create_worker_on_cpu(9)kthread_queue_work(9)kthread_delayed_work_timer_fn(9)kthread_queue_delayed_work(9)kthread_flush_work(9)kthread_mod_delayed_work(9)kthread_cancel_work_sync(9)kthread_cancel_delayed_work_sync(9)kthread_flush_worker(9)kthread_destroy_worker(9)kthread_use_mm(9)kthread_unuse_mm(9)kthread_associate_blkcg(9)kthread_blkcg(9)
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
- 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