proper way to terminate a kthread when the parent process dies ?

Konstantin Belousov kostikbel at gmail.com
Tue Aug 4 16:46:09 UTC 2015


On Tue, Aug 04, 2015 at 06:27:46PM +0200, Luigi Rizzo wrote:
> Specifically, our two threads implement the host part of a virtualized network
> interface and operate in a way that is very similar to an interrupt handler,
> or vhost-net in KVM. In principle, the user process that issues
> the system call could be unaware of the existence and number of
> those threads; that is why we went for a "kernel thread" created
> within the kernel.

You might try to construct this using the recently added
initialize_thread argument to the thread_create(). Specifically,
you could call cpu_set_fork_handler() there, instead of
cpu_set_upcall(_kse)(), to leave the thread in the kernel and force it
to execute your function.


More information about the freebsd-current mailing list