On Thu, 3 Apr 2025 12:32:35 +0900 Takashi Yano wrote: > > Still, I wonder in which thread raw_write is running during fork(). > > Weird enough, raw_write() is called in the main thread (_main_tls). > Any chance, fixup_after_fork() is not called?
It seems that raw_write() is called before returning from pthread::atforkchild() in fork::child(). Moving _my_tls.fixup_after_fork() before atforkchild() seems to solve the issue. What about: ld_preload (); fixup_hooks_after_fork (); ch.rd_proc_pipe = ch.wr_proc_pipe = NULL; ? Should any of these be before pthread::atforkchild() asl well? I'm now performing a long-run test with the patch: diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 0742ab363..28daf2682 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -187,7 +187,6 @@ frok::child (volatile char * volatile here) ForceCloseHandle1 (fork_info->forker_finished, forker_finished); - pthread::atforkchild (); cygbench ("fork-child"); ld_preload (); fixup_hooks_after_fork (); @@ -196,6 +195,7 @@ frok::child (volatile char * volatile here) rd_proc_pipe that would be an invalid handle. In the case of wr_proc_pipe it would be == my_wr_proc_pipe. Both would be bad. */ ch.rd_proc_pipe = ch.wr_proc_pipe = NULL; + pthread::atforkchild (); CloseHandle (hParent); hParent = NULL; cygwin_finished_initializing = true; -- Takashi Yano <takashi.y...@nifty.ne.jp> -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple