SIGALRM is not interrupting a blocking write to a pipe
Takashi Yano
takashi.yano@nifty.ne.jp
Mon Jul 1 11:43:28 GMT 2024
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.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
More information about the Cygwin
mailing list