| delorie.com/archives/browse.cgi | search |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 46AN2ZgQ1418034 |
| 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=douIUSyG | |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 2B227387100A |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1720652553; | |
| bh=p94Jpt3tHj+NofkDVo5CFTDqjXCGcTbHZFnX4cXCsfw=; | |
| h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: | |
| List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: | |
| From; | |
| b=douIUSyGmSmNwun7yFWgOFBx6JJxekoqVjPC/XT3bMz8qFk52qG6Cqb1r7zzZYdMu | |
| cPG8D4kFX+pfonrfh1qI9O7S+tB5X+38kidimmdFxeOe4JS7z/SZD+XJ2LVBzvsgdW | |
| kvIf+PHPDok9XdUjI8uEcuAU43wYzGiW94jCsCQE= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 sourceware.org 74960386103F |
| ARC-Filter: | OpenARC Filter v1.0.0 sourceware.org 74960386103F |
| ARC-Seal: | i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720652497; cv=none; |
| b=gCnQal3sxcgH8rLf66+ECTyQYiQ/TLsbE+ZnUi3eCHsiv+kIKUOuGMY/GkHJOMhRRwi7wtxQR5UBmSNpaUi+iZA2TauSn3UsJeAM8E4VV+u0Rn6Hdp7pZ6wuBC/jvKT4whm0Nj0uepE/pr7U0rnFntbIEtAxkr2lSCeFBFSAxIw= | |
| ARC-Message-Signature: | i=1; a=rsa-sha256; d=sourceware.org; s=key; |
| t=1720652497; c=relaxed/simple; | |
| bh=sWbdnXv8WAqwq3BQzTOzoIgg+JE5CJ2VlRxjF6YqxY8=; | |
| h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; | |
| b=rRQp3l6fi6y9KNLw9iqqDdA7B1AJEwpyfjR2scq5tG4h2SERr8Tlxn7/XV9YH20GOz6xMKnz8bU+ulv5frvXrHK+fPOayMsn97W1no43Khfc18cORdSE0IDIUT/iYhmkpx16mQ4u4Nrrz7+od5JEojwxQ0xlW7zg+/dI/K4HVJ4= | |
| ARC-Authentication-Results: | i=1; server2.sourceware.org |
| Date: | Thu, 11 Jul 2024 08:01:30 +0900 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: SIGALRM is not interrupting a blocking write to a pipe |
| Message-Id: | <20240711080130.a1c3b9ad0bc457ce9e0d9358@nifty.ne.jp> |
| In-Reply-To: | <20240701204328.839e7bbc7b04292825b3fdc2@nifty.ne.jp> |
| References: | <10838112-58af-4b53-baac-39ab849662a4 AT gmail DOT com> |
| <20240701204038 DOT 1a80dd18267a2302ca838e3e AT nifty DOT ne DOT jp> | |
| <20240701204328 DOT 839e7bbc7b04292825b3fdc2 AT nifty DOT ne DOT jp> | |
| X-Mailer: | Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) |
| Mime-Version: | 1.0 |
| X-Spam-Status: | No, score=-4.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, |
| DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, | |
| SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 | |
| X-Spam-Checker-Version: | SpamAssassin 3.4.6 (2021-04-09) on |
| server2.sourceware.org | |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.30 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Unsubscribe: | <https://cygwin.com/mailman/options/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe> | |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | Takashi Yano via Cygwin <cygwin AT cygwin DOT com> |
| Reply-To: | Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp> |
| Errors-To: | cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com |
| Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
This is a multi-part message in MIME format.
--Multipart=_Thu__11_Jul_2024_08_01_30_+0900_rnT/=Zcj=z22qb4p
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
On Mon, 1 Jul 2024 20:43:28 +0900
Takashi Yano wrote:
> On Mon, 1 Jul 2024 20:40:38 +0900
> Takashi Yano wrote:
> > On Mon, 6 May 2024 23:01:49 +0300
> > ilya Basin wrote:
> > > I need your help with troubleshooting an issue with "pv": https://codeberg.org/a-j-wood/pv/issues/87
> > >
> > > This app uses SIGALRM to interrupt a blocking write to STDOUT and read more data into the buffer.
> > > On Linuxes write() returns 0 after the signal, but on Cygwin even though the signal handler is called, the write call does not return, at least when writing to a pipe.
> >
> > What Linux environment you assume? I run the STC below on Debuan GNU/Linux,
> >
> > #include <stdio.h>
> > #include <unistd.h>
> > #include <signal.h>
> > #include <errno.h>
> > #include <signal.h>
> > #include <string.h>
> >
> > void handler(int sig)
> > {
> > printf("sig=%d\n", sig);
> > }
> >
> > int main()
> > {
> > int fd[2];
> >
> > signal(SIGALRM, handler);
> > pipe(fd);
> > for (;;) {
> > int l = write(fd[1], "A", 1);
> > if (l == 1) {
> > printf("."); fflush(stdout); /* Normal */
> > } else {
> > printf("%d: %s\n", l, strerror(errno)); /* Interrupt */
> > }
> > }
> > }
> >
> > but,
> > kill -ALRM <pid of STC>
> > does not make output /* Interrupt */ line, but only /* Normal */ line.
>
> and
> sig=14
> as well.
>
> > uname -a:
> > Linux debian2 6.1.0-21-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.90-1 (2024-05-03) x86_64 GNU/Linux
> >
> > The behaviour is same with cygwin.
I got it. signal() sets SA_RESTART flag which prevent write()
from interrupt. Without SA_RESTART, I can see the behaviour
difference between linux and cygwin.
Now we are discussing how to fix that problem. Thansk.
P.S.
Attached is the my second STC. The STC without argument behaves
differently on cygwin from linux.
--
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
--Multipart=_Thu__11_Jul_2024_08_01_30_+0900_rnT/=Zcj=z22qb4p
Content-Type: text/x-csrc;
name="pipew.c"
Content-Disposition: attachment;
filename="pipew.c"
Content-Transfer-Encoding: 7bit
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
void handler(int sig)
{
fprintf(stderr, "sig=%d\n", sig);
}
int main(int argc, char *argv[])
{
int fd[2] = {0, 1};
struct sigaction sa = {0,};
sa.sa_handler = handler;
if (argc > 1 && atoi(argv[1])) {
sa.sa_flags = SA_RESTART;
}
sigaction(SIGALRM, &sa, NULL);
if (isatty(1)) {
pipe(fd);
}
for (;;) {
int l = write(fd[1], "A", 1);
if (l == 1) {
fprintf(stderr, "."); fflush(stderr);
} else {
fprintf(stderr, "%d: %s\n", l, strerror(errno));
}
}
}
--Multipart=_Thu__11_Jul_2024_08_01_30_+0900_rnT/=Zcj=z22qb4p
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--
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
--Multipart=_Thu__11_Jul_2024_08_01_30_+0900_rnT/=Zcj=z22qb4p--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |