[PATCH v2 1/4] um: Add pthread-based helper support

Johannes Berg johannes at sipsolutions.net
Wed Mar 19 02:11:18 PDT 2025


On Thu, 2025-03-06 at 23:07 +0800, Tiwei Bie wrote:
> Introduce a new set of utility functions that can be used to create
> pthread-based helpers. Helper threads created in this way will ensure
> thread safety for errno while sharing the same memory space.

I'm not sure at the moment exactly what the issue is, but with the next
patch, I cannot shut down cleanly.

> +void os_kill_helper_thread(struct os_helper_thread *td)
> +{
> +	pthread_kill(td->handle, SIGKILL);

This ends up killing everything.

I thought maybe it's because all the signals are blocked:

> +int os_run_helper_thread(struct os_helper_thread **td_out,
> +			 void *(*routine)(void *), void *arg)
> +{
> [...]
> +	sigfillset(&sigset);
> +	if (sigprocmask(SIG_SETMASK, &sigset, &oset) < 0) {
> +		err = -errno;
> +		kfree(td);
> +		return err;
> +	}
> +
> +	err = pthread_create(&td->handle, NULL, routine, arg);

but removing SIGKILL from that set doesn't make a difference, and
perhaps this should be using pthread_sigmask(), e.g. if glibc doesn't
retrieve the values from the kernel but uses the ones last set by that
function?

Anyway, the issue is I cannot shut down, I get:

reboot: Power down
Killed

and the terminal isn't cleaned up, i.e. shutdown code isn't run.

Please check :)

johannes



More information about the linux-um mailing list