RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2018077 - [RHEL 8.4/Gawk] incorrect error code with command gawk
Summary: [RHEL 8.4/Gawk] incorrect error code with command gawk
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: gawk
Version: 8.4
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jakub Martisko
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks: 2055107
TreeView+ depends on / blocked
 
Reported: 2021-10-28 07:54 UTC by Rajesh Dulhani
Modified: 2022-05-10 16:59 UTC (History)
2 users (show)

Fixed In Version: gawk-4.2.1-3.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2055107 (view as bug list)
Environment:
Last Closed: 2022-05-10 15:33:18 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-100910 0 None None None 2021-10-28 07:54:52 UTC
Red Hat Product Errata RHBA-2022:2122 0 None None None 2022-05-10 15:33:21 UTC

Description Rajesh Dulhani 2021-10-28 07:54:04 UTC
Description of problem:

problem with error code with command gawk in redhat 8


Version-Release number of selected component (if applicable):
gawk-4.2.1-2.el8.x86_64.rpm


How reproducible:

script used to see difference :


#!/usr/bin/gawk -f

BEGIN{
rc=0;

cmd1="unzip -o -d /var/tmp /var/tmp/testdco.zip";

#CAS 1
while (cmd1|getline){
continue;
}
rc=close(cmd1);
print "Rc (pas bon)="rc;


# CAS 2
while ( cmd1|getline){
cmd="echo"
cmd|getline
close(cmd)
# unzipedFile=$0;
}
rc=close(cmd1);
print "RC correctt="rc;



#CAS 3
while (cmd1|getline){
continue;
}
rc=close(cmd1);
print "rc pas bon ="rc

exit rc;
}

END{

exit rc;
}

Steps to Reproduce:
1.
2.
3.

Actual results:


Redhat 8: it is not ok 

[root@rhuxv-tstlu001d tmp]# ./testGawk > /var/tmp/result-gawk

[root@rhuxv-tstlu001d tmp]# cat /var/tmp/result-gawk
Rc (pas bon)=9
RC correctt=2304
rc pas bon =9
[root@rhuxv-tstlu001d tmp]# rpm -qa | grep -i gawk
gawk-4.2.1-1.el8.x86_64


test in RedHat 7 : ok 
[root@rhuxv-rhnlu001d tmp]#  ./testGawk > /var/tmp/result-gawk

[root@rhuxv-rhnlu001d tmp]# cat /var/tmp/result-gawk
Rc (pas bon)=2304
RC correctt=2304
rc pas bon =2304
[root@rhuxv-rhnlu001d tmp]# rpm -qa | grep -i gawk
gawk-4.0.2-4.el7_3.1.x86_64
[root@rhuxv-rhnlu001d tmp]#

TEST 2 is ok


Expected results:

expected in redhat 8 to have same result (error code 2304)  for all case


Additional info:

Comment 1 Jakub Martisko 2021-11-01 10:56:49 UTC
I am not exactly sure what is the purpose of the script but the return value of close is the exit status of the command used to open the pipe, as described in [1]. So for:

cmd1="unzip -o -d /var/tmp /var/tmp/testdco.zip";

#CAS 1
while (cmd1|getline){
continue;
}
rc=close(cmd1);
print "Rc (pas bon)="rc;

the rc should be the exit status of unzip. For unzip, the exit value of 9 means "the specified zipfiles were not found."



[1]: https://www.gnu.org/software/gawk/manual/html_node/Close-Files-And-Pipes.html#table_002dclose_002dpipe_002dreturn_002dvalues

Comment 2 Damien Cochet 2022-01-11 08:18:23 UTC
Hi, I'm the person who detect this bug.
The only purpose of this script is to highlight a bug that occurs when cmd|getline are nested.
We detect the bug in a much more "complex script" but, we try to simplify as much as possible.
So the script is stupid, but running it in RHEL7, and RHEL8 leads to the described results

To reproduce this bug you have to create a /var/tmp/testdco.zip (touch /var/tmp/testdco.zip for instance)

If the file exists but is not valid, unzip will fail with RC=9 too.

but in the script (CAS2), when closing unzip command you will receive RC=2304 instead of RC=9 (which is the expected value)

RC=2304 = 256*9 which is the behaviour of previous versions...

Hope it will help.

Comment 9 errata-xmlrpc 2022-05-10 15:33:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (gawk bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2122


Note You need to log in before you can comment on or make changes to this bug.