The patch introduces general error handling in gentls_offsets. Explicit
validation for the presence of gawk is no longer required. gawk has been
utilizing 'exit', which might lead to broken pipes in the current
implementation. When 'exit' is triggered, gawk finishes the process,
however the upstream command might still be active. This has been resolved
by avoiding the use of 'exit' in gawk.
---
winsup/cygwin/scripts/gentls_offsets | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/winsup/cygwin/scripts/gentls_offsets
b/winsup/cygwin/scripts/gentls_offsets
index bf84dd0cb..a364ea57a 100755
--- a/winsup/cygwin/scripts/gentls_offsets
+++ b/winsup/cygwin/scripts/gentls_offsets
@@ -4,14 +4,9 @@ input_file=$1
output_file=$2
tmp_file=/tmp/${output_file}.$$
+set -eo pipefail # fail if any command or pipeline fails
trap "rm -f ${tmp_file}" 0 1 2 15
-# Check if gawk is available
-if ! command -v gawk &> /dev/null; then
- echo "$0: gawk not found." >&2
- exit 1
-fi
-
# Preprocess cygtls.h and filter out only the member lines from
# class _cygtls to generate an input file for the cross compiler
# to generate the member offsets for tlsoffsets-$(target_cpu).h.
@@ -29,14 +24,13 @@ gawk '
}
/^class _cygtls$/ {
# Ok, bump marker, next we are expecting a "public:" line
- marker=1;
+ if (marker == 0) marker=1;
}
/^public:/ {
# We are only interested in the lines between the first (marker == 2)
# and the second (marker == 3) "public:" line in class _cygtls. These
# are where the members are defined.
if (marker > 0) ++marker;
- if (marker > 2) exit;
}
{
if (marker == 2 && $1 != "public:") {
--
2.39.5