{"thread":{"id":"66702","subject":"Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal","startedAt":"2026-10-29T14:13:08Z","lastAt":"2026-10-29T14:13:08Z","messageCount":1,"participants":["ian4hu"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556785","messageId":"20261029141308.163936-1-hu2008yinxiang@163.com","threadId":"66702","inReplyTo":null,"subject":"Re: [PATCH] sigchain: recover from concurrent double-pops of the same signal","fromName":"ian4hu","fromEmail":"hu2008yinxiang@163.com","sentAt":"2026-10-29T14:13:08Z","receivedAt":"2026-10-29T14:13:08Z","isPatch":true,"sender":{"key":"hu2008yinxiang@163.com","avatar":null},"body":"Hi Phillip,\n\nThanks for the follow-up.  All three points make sense; let me\nconfirm what I plan to do so we are on the same page.\n\nOn SIGPIPE: you are right that my wording was wrong.  Blocking is\nnot ignoring, and the write() fails with EPIPE either way.  What\nchanges is that the signal is not delivered while it is blocked;\nand since a SIGPIPE raised by a write is thread-directed, it stays\npending on the writing thread instead of being picked up by the\nmain thread.  If that thread never unblocks it, it is never\ndelivered, so a worker that blocks SIGPIPE simply stops dying of\nit.  I left SIGPIPE out precisely to keep the \"upstream of a pipe\ndies of SIGPIPE\" behaviour that common-init.c restores.  The set I\nplan to block is SIGINT, SIGHUP, SIGTERM and SIGQUIT.  If you\nthink SIGPIPE belongs in it too, I will add it.\n\nOn the blocking pattern: agreed.  I will block once around the\nspawn loop and restore before the join loop, rather than around\neach pthread_create(), via a small guard pair\n\n    struct signal_mask_guard guard;\n\n    block_sigchain_signals(&guard);\n    for (i = 0; i < nr_threads; i++)\n        pthread_create(&t[i], NULL, fn, &data[i]);\n    restore_sigchain_signals(&guard);\n\nplus a git_pthread_create() wrapper on top for the single-thread\ncall sites.  The loops I have in mind are preload_index(),\nindex-pack, pack-objects, grep, name-hash and the read-cache entry\nloader; the fsmonitor--daemon and simple-ipc threads I would leave\nalone for now, as they have their own lifecycle and signal\nhandling.\n\nOn sigaction: agreed as well.  The handled signal is deferred by\ndefault, so the remaining hole is a handler being interrupted by\none of the other common signals that share the same handler.  I\nwill set sa_mask to sigfillset() and save/restore the whole\nstruct sigaction, so pop() does not clobber the caller's\nsa_flags/sa_mask.\n\nThe one gap I cannot close is a thread created by library code\nrather than by us.  libcurl's threaded resolver is the case I am\naware of, depending on how libcurl is built; I do not know of an\nin-tree instance, and I will mention it in the cover letter rather\nthan claim it is covered.\n\nSo I will drop this patch and build the series along those lines.\nAs you suggested, I will wait a few days for Peff and Junio to\ncomment before spending much time on it; if nobody objects I will\nsend the replacement as v2.\n\nThanks,\nian4hu\n\n\n"}]}