kthread_stop(9)
π kthread_stop(9)
okay so bestie, welcome to the kthread_stop page β straight out of the Kernel API Manual (that's the 9 in the name, iykyk). This is the function that tells a kthread to wrap it up and then actually waits around for it to leave. Iconic behavior, honestly.
β¨ NAME β¨
kthread_stop β stop a thread created by kthread_create(). That's it. That's the whole job. π
β¨ SYNOPSIS β¨
int kthread_stop (struct task_struct *k );
β¨ ARGUMENTS β¨
kβ the thread created bykthread_create. yeah, this exact one, no substitutions π«Ά
β¨ DESCRIPTION β¨
So here's the vibe: kthread_stop sets kthread_should_stop for k so it returns true, wakes it up, and then waits for it to exit. Like a bestie standing outside the dressing room. π§
And lowkey the cool part β you can also call this right after kthread_create instead of calling wake_up_process: the thread will exit without calling threadfn. Not me skipping straight to the exit. π
β οΈ real talk though: ifthreadfnmay callkthread_exititself, the caller must ensuretask_structcan't go away. no cap, this one matters.
It returns the result of threadfn, or -EINTR if wake_up_process was never called. πΈ
π SEE ALSO π
- Kernel file
./kernel/kthread.c kthread_should_stop(9)kthread_should_park(9)kthread_freezable_should_stop(9)kthread_func(9)kthread_data(9)kthread_probe_data(9)kthread_complete_and_exit(9)kthread_create_on_node(9)kthread_bind(9)kthread_create_on_cpu(9)kthread_unpark(9)kthread_park(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 whole page, bestie β go read some more kthread lore, it's giving main character energy fr fr π
source dir ./kernel Β· version/date October 2026 Β· slay, you made it to the end, ily π¦β¨
π¦ 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