Subject: Incorrect return value for SIGPIPE case

From: Sachin T <[email-masked]>
Date: Wed, 11 Dec 2024 18:29:41 +0530

Hi Grep Team,

I am running version 3.11 of grep on the IBM z/OS platform.

I am testing a scenario where grep's output is redirected to a closed pipe.
This was expected to raise a SIGPIPE signal and return an exit status of
141.

Upon inspecting the code, I noticed that the signal is raised by fclose,
which is executed as part of the *clean_up_stdout* handler registered with
atexit. However, on the z/OS platform, when a signal is raised during the
execution of an atexit-registered function, the exit status of the program
is determined by the main program's return status rather than the signal's
exit code. In this case, the exit status is 0, which does not reflect the
SIGPIPE signal.

Could you suggest the preferred solution for handling this situation on the
z/OS platform? Additionally, would it be possible for this behavior to be
addressed as a bug fix specific to the z/OS platform in a future release?

Looking forward to your response.

Regards,
Sachin