DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 59RJC9FB474973 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 59RJC9FB474973 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=R41Z3vkj X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6EDB23858C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1761592328; bh=IHUfzQpTv5+Ts6bQVf1aLabnmfIbcl5XFjZ8RBzmgHM=; h=Resent-From:Resent-Date:Resent-To:Date:To:Subject:References: In-Reply-To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=R41Z3vkjcaDSms0BQAvSa5e4E8oJsbzya8L9o9DerHmCYqErYRx2YILu81ibXJ7Ms joyN/H1MeiaHvIT1FkocwuA4ZjnEnzSMUqn9oMHk0MOqZIse2jgSuvKVu4nqcXoRsD dKNmojpt7HVj9hhPZTAynl4YLkTXYo0OQ6aq+FQg= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DBB43858C40 Resent-From: root Resent-Date: Mon, 27 Oct 2025 19:10:22 +0000 Resent-Message-ID: Resent-To: cygwin AT cygwin DOT com X-Original-To: spam AT localhost Delivered-To: spam AT localhost DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACE0A3858CB6 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ACE0A3858CB6 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760569371; cv=none; b=MuaLG8oJwQztqv1QsC0pJPfrzKAyqE8zRol0jlFxz4yzegfsSQLK0Y3SLCKu0/ahy1R86CRPx4as09UU7VRezBDW5Sm31sI5EEsqBZwHNSyMhPkFCvICOwUel3yKbD8w3BUWET1zp6VYaBUyEXD6TdaF0jlJ0gLyxKP4YHlW33Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1760569371; c=relaxed/simple; bh=O98Gc9fXvc45JVJoLzvq7dhQBpOlrRBNxLnPt9GQxH8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=k4+CY+MgcR1Z+0t5s629fqx8zkughdPhM2p05fRo6miiRxSUzg4kTyHTmKWz1xUFldO8+1pIqGwVLkTHWACBYH/E8UEf+xqslD7YDtN9Kl2zQ/QHti+BNr4PJm/HprgkDiCrn0E7EgkCC3BCRU5bB3H4EKqG1i5HXDztnTF4kEs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ACE0A3858CB6 Date: Thu, 16 Oct 2025 10:02:45 +1100 To: cygwin AT cygwin DOT com Subject: Re: bash hangs when executing a script with a here document larger than 64 KiB Message-ID: Mail-Followup-To: cygwin AT cygwin DOT com References: <6844953 DOT 4vTCxPXJkl AT nimes> <6f388d6d-e0b1-46a6-a4fb-9f1e008345a7 AT SystematicSW DOT ab DOT ca> <7551137c-8ba5-afd8-b7aa-30a18661cc6d AT wisemo DOT com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Atmail-Id: duncan_roe AT optusnet DOT com DOT au X-atmailcloud-spam-action: no action X-Cm-Envelope: MS4xfEzUerF8/zaLYkVGdwgHo3tllmtax4FMuJDQdbnBtQKUZ0CKASCgncGGEE//A8P3//bfcNEEmEnw/JH1ndnzQgfpgXDrTZ6eUl2hhiksBIonY/C6X6AL Ox7A9NaxaiqanexiKAdKuxbweVLSb1Xd36/1IieQBj2K/oPmj7o7sYTPxEToZS4UwIq1gf7Voxcu+g== X-Cm-Analysis: v=2.4 cv=bvdKBlai c=1 sm=1 tr=0 ts=68f02818 a=6uXT7DF6Lsg9xELlzDb1tA==:117 a=6uXT7DF6Lsg9xELlzDb1tA==:17 a=PgLrZpBLtpqfETd_:21 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=u5XXcUwOAAAA:8 a=oC-U7Zc_NDZCH3J504gA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=9Wj8dLAF7nyNpo3U2r0D:22 X-atmailcloud-route: unknown X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Duncan Roe via Cygwin Reply-To: Duncan Roe Content-Type: text/plain; charset="utf-8" Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 59RJC9FB474973 On Sun, Oct 05, 2025 at 08:03:34AM +0200, cygwin wrote: > On 10/5/2025 6:57 AM, Duncan Roe via Cygwin wrote: > > If the bug is to persist, I suggest to munge psize.c:- > > > > | *** builtins/psize.c.bu Fri Aug 15 05:56:53 2008 > > | --- builtins/psize.c Sun Oct 5 14:06:50 2025 > > | *************** > > | *** 51,57 **** > > | sigpipe (sig) > > | int sig; > > | { > > | ! fprintf (stderr, "%d\n", nw); > > | exit (0); > > | } > > | > > | --- 51,57 ---- > > | sigpipe (sig) > > | int sig; > > | { > > | ! fprintf (stderr, "%d\n", nw - 128); > > | exit (0); > > | } > > | > > > > N.B. blank lines (after removing 1st 2 chars) have 2 trailing spaces. > > > > Cheers ... Duncan. > > > Subtracting 128 (the granularity of the test code), seems very arbitrary and > kludgy. Kludgy?? It's the expected result when you write that number of bytes. Anyway, it's a *tested* and *working* 1-line fix. Any 1-line fix is a good fix. > > An obvious simplification is to disable SIGPIPE and use a loop that ends > when 0or -1 > is returned, like this: > > /* The following code was written directly in the mail and not tested */ Clearly not tested 🙄 > >   /* TODO: ignore SIGPIPE instead of setting a handler */ > > nw = 0; > for(;;) > { > i = write (1, buf, 128); > if (i <= 0) > break; >  nw += i; > } > /* These are the error codes in the POSIX write(3P) man page > * associated with hitting the pipe limit or similar, > * maybe this code should accept a few more error codes in > * real world use for this. > */ > if (errno == EPIPE || errno == ENOSPC || errno == EAGAIN || > errno == EFBIG || errno == ENOBUFS) > fprintf (stderr, "%d\n", nw); > else > perror (argv[0]); Doesn't work. As per my previous email, the over-capacity write only returns on receipt of a signal, but before the signal is delivered. It *might* work if the pipe were made non-blocking, but that's a lot of code churn compared with a 1-liner. > > Another simplification would be for psize.c to open its own pipe and > simply never read from it, thus removing any dependency on how the build > time shell and sleep programs handle the pipe. Won't work, see above. > > -- > Jakob Bohm, CIO, partner, WiseMo A/S. https://www.wisemo.com > Transformervej 29, 2860 Soborg, Denmark. direct: +45 31 13 16 10 > > This message is only for its intended recipient, delete if misaddressed. > WiseMo - Remote Service Management for PCs, Phones and Embedded Cheers ... Duncan. -- 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