[PATCH] cygthread: suspend thread before terminating.
Jeremy Drake
cygwin@jdrake.com
Thu Nov 14 00:28:55 GMT 2024
On Tue, 12 Nov 2024, Jeremy Drake via Cygwin-patches wrote:
> diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
> index 81b6c31695..360bdac232 100644
> --- a/winsup/cygwin/sigproc.cc
> +++ b/winsup/cygwin/sigproc.cc
> @@ -410,7 +410,8 @@ proc_terminate ()
> if (!have_execed || !have_execed_cygwin)
> chld_procs[i]->ppid = 1;
> if (chld_procs[i].wait_thread)
> - chld_procs[i].wait_thread->terminate_thread ();
> + if (!CancelSynchronousIo (chld_procs[i].wait_thread->thread_handle ()))
> + chld_procs[i].wait_thread->terminate_thread ();
> /* Release memory associated with this process unless it is 'myself'.
> 'myself' is only in the chld_procs table when we've execed. We
> reach here when the next process has finished initializing but we
>
It turns out that in some cases (that I never saw when testing on ARM64
but apparently happen on native x86_64) the CancelSynchronousIo results in
the ReadFile in proc_waiter returning ERROR_OPERATION_ABORTED, which is
logged to the console. I'll be submitting a v2 of this patch with that
handled (the behavor is otherwise fine, just the output is spurious since
that error is expected now) once I get confirmation that it's working.
More information about the Cygwin-patches
mailing list