bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Ignored SIGPIPE with line bufferization (wrapped by 'stdbuf -oL')


From: Andrew J. Schorr
Subject: Re: Ignored SIGPIPE with line bufferization (wrapped by 'stdbuf -oL')
Date: Sun, 31 Jul 2022 10:34:43 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Sun, Jul 31, 2022 at 12:45:45AM -0600, arnold@skeeve.com wrote:
> That'd be nice. I don't really have the cycles; if you or Nikita
> would do it, I'd appreciate it. As the patch is generic across POSIX
> systems, I will leave it in place in any case.

This seems to be a simple C reproducer (attached).

On CentOS Stream 9:

With no buffering, it fails when it tries to write the second batch
of 4096 bytes:

bash-5.1$ (fwrite hello 5000 | head -n1) 2>&1 | tail
1357. fwrite wrote 6 bytes and ferror is 0
1358. fwrite wrote 6 bytes and ferror is 0
1359. fwrite wrote 6 bytes and ferror is 0
1360. fwrite wrote 6 bytes and ferror is 0
1361. fwrite wrote 6 bytes and ferror is 0
1362. fwrite wrote 6 bytes and ferror is 0
1363. fwrite wrote 6 bytes and ferror is 0
1364. fwrite wrote 6 bytes and ferror is 0
1365. fwrite wrote 6 bytes and ferror is 0
1366. fwrite returned 2 instead of 6

With no buffering, fwrite fails at some point; the number of successful
writes is inconsistent:

bash-5.1$ (fwrite -0 hello 5000 | head -n1) 2>&1 | tail
29. fwrite wrote 6 bytes and ferror is 0
30. fwrite wrote 6 bytes and ferror is 0
31. fwrite wrote 6 bytes and ferror is 0
32. fwrite wrote 6 bytes and ferror is 0
33. fwrite wrote 6 bytes and ferror is 0
34. fwrite wrote 6 bytes and ferror is 0
35. fwrite wrote 6 bytes and ferror is 0
36. fwrite wrote 6 bytes and ferror is 0
37. fwrite returned 0 instead of 6
hello

With line buffering, it never fails (although ferror gets set at some
point):

bash-5.1$ (fwrite -l hello 5000 | head -n1) 2>&1 | tail
4991. fwrite wrote 6 bytes and ferror is 1
4992. fwrite wrote 6 bytes and ferror is 1
4993. fwrite wrote 6 bytes and ferror is 1
4994. fwrite wrote 6 bytes and ferror is 1
4995. fwrite wrote 6 bytes and ferror is 1
4996. fwrite wrote 6 bytes and ferror is 1
4997. fwrite wrote 6 bytes and ferror is 1
4998. fwrite wrote 6 bytes and ferror is 1
4999. fwrite wrote 6 bytes and ferror is 1
5000. fwrite wrote 6 bytes and ferror is 1

Just need to figure out where to send this...

Regards,
Andy

Attachment: fwrite.c
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]