[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fflush & close behavior not well-defined
From: |
arnold |
Subject: |
Re: fflush & close behavior not well-defined |
Date: |
Wed, 30 Sep 2020 23:12:38 -0600 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
I had an epiphany last night as to what the issue is, but I'd
already shut down my laptop.
Gawk isn't at fault, nor is the C library. It's the bash version.
On Fedora 7:
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
On Ubuntu 18.04:
$ bash --version
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
Why does it matter? Remember that the string that can be used for
pipelines can be any shell command. Gawk runs /bin/sh to execute the
command; the exit status that comes back *is that of the shell*, not
of the command it runs!
To wit, if we modify your one-line slightly by using exec:
$ cat x.awk
BEGIN { LINT = 1 }
BEGIN {print "hello" |& "exec cat"; print close("exec cat")}
On Fedora:
$ ./gawk -f x.awk
gawk: x.awk:2: warning: failure status (269) on two-way pipe close of `exec
cat': Success
269
And now on Ubuntu:
$ ./gawk -f x.awk
gawk: x.awk:2: warning: failure status (269) on two-way pipe close of `exec
cat': Success
269
Ta da!
The previous 141 came from bash, where:
1. The exit status of the shell is the status of the last command it ran
2. If the command exited upon signal, the status is 128 + the signal number
I *knew* that that was going on somewhere!
Apparently Bash changed at some point, from passing up the unadulterated
wait(2) exit status, to working as just described.
I will see if I can adjust the test.
And WOW! Talk about dark corners...
Thanks,
Arnold
P.S. I can't seem to duplicate this issue directly at the command line...
Oh well.
- Re: fflush & close behavior not well-defined,
arnold <=
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/10/01
- Re: fflush & close behavior not well-defined, arnold, 2020/10/01
- Re: fflush & close behavior not well-defined, Andrew J. Schorr, 2020/10/01
- Re: fflush & close behavior not well-defined, Chet Ramey, 2020/10/01
- Re: fflush & close behavior not well-defined, arnold, 2020/10/01
- Re: fflush & close behavior not well-defined, Chet Ramey, 2020/10/01
- Re: fflush & close behavior not well-defined, arnold, 2020/10/02
Re: fflush & close behavior not well-defined, Chet Ramey, 2020/10/01