kthread_stop(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 by kthread_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: if threadfn may call kthread_exit itself, the caller must ensure task_struct can'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 🌈


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