bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Does gawk deal with signal pipe correctly?


From: arnold
Subject: Re: [bug-gawk] Does gawk deal with signal pipe correctly?
Date: Sun, 17 Jun 2018 01:06:49 -0600
User-agent: Heirloom mailx 12.4 7/29/08

On a Redhat system using current code and your file I got 0 0 0 one time
and 0 141 0 the rest of the times I tried. It appears to be a timing
issue.

The pipe(7) man page says

        In Linux versions before 2.6.11, the capacity of a pipe was the same as
        the system page size (e.g., 4096 bytes on i386).  Since Linux 2.6.11,
        the pipe capacity is 65536 bytes.

Your file is a little over 18000 bytes, so it fits entirely into a
single pipe buffer.  It looks like the 0 0 0 happens when gawk succeeds to
read and write the data before head runs, and SIGPIPE otherwise.

Unless there is a way to reproduce this consistently so that I can
trace the code in a debugger, there's not a lot more I can do.

Thanks,

Arnold

Peng Yu <address@hidden> wrote:

> You must use the file that I provided to reproduce the problem `seq
> 10000000` will not reveal the problem as I have shown in my original
> post.
>
> I also tested on Ubuntu. Sometimes it shows 0 1 0 and sometimes it shows 0 0 
> 0.
>
> $ cat DCt7x2zD | awk '{ print }' | head -n 1
>
> $ echo address@hidden
> 0 1 0
> $ awk --version | head -n 1
> GNU Awk 4.2.0, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
>
>
> On Sat, Jun 16, 2018 at 1:51 PM,  <address@hidden> wrote:
> > Hello.
> >
> > I don't think this is an awk issue.  In any case, I can't
> > reproduce the problem:
> >
> >         $ gawk --version | sed 1q
> >         GNU Awk 4.2.0, API: 2.0 (GNU MPFR 3.1.4, GNU MP 6.1.0)
> >         [tanda:pts/2 arnold]$ for i in nawk mawk gawk
> >         > do
> >         > echo === $i
> >         > seq 10000000 | $i '{ print }' | head -1
> >         > echo address@hidden
> >         > done
> >         === nawk
> >         1
> >         141 141 0
> >         === mawk
> >         1
> >         141 141 0
> >         === gawk
> >         1
> >         141 141 0
> >
> > Arnold
> >
> > Peng Yu <address@hidden> wrote:
> >
> >> Hi,
> >>
> >> $ seq 10000000 | awk -e '{ print }' | head -n 1
> >> 1
> >> $ echo "address@hidden"
> >> 141 141 0
> >> $ tmpfile=$(mktemp -u)
> >> $ seq 10000000 > "$tmpfile"
> >> $ cat "$tmpfile" | awk -e '{ print }' | head -n 1
> >> 1
> >> $ echo "address@hidden"
> >> 141 141 0
> >>
> >> In the following case, I see that awk sometimes return 1 instead of 0
> >> for the input tmp2.txt (download at
> >> https://pastebin.com/raw/DCt7x2zD). But I never see awk returns 141
> >> for this file. Is this behavior of awk correct? Should it always
> >> return 141?
> >>
> >> $ cat < tmp2.txt | awk -e '{ print }' | head -n 1
> >>
> >> $ echo address@hidden
> >> 0 1 0
> >>
> >> --
> >> Regards,
> >> Peng
>
>
>
> -- 
> Regards,
> Peng



reply via email to

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