From 7e69aff916c33e4486ed3bda690b7e6d4d99df7b Mon Sep 17 00:00:00 2001 From: Qin Fandong Date: Dec 02 2024 09:11:26 +0000 Subject: [PATCH 1/2] No longer trap signal 0 (reserved) and 17 (SIGCHLD) in rpminfo Signal number 0 is reserved for use as kill(pid, 0), to test whether a process exists without sending it a signal, we shouldn't trap this signal. Signal number 17 (SIGCHLD) is triggered at least once during each bash fork subprocess, and associating this signal with cleanup code through a trap can cause rpminfo to unexpectedly trigger cleanup (and exit with error code -1). --- diff --git a/rpminfo b/rpminfo index 98adc63..796a296 100644 --- a/rpminfo +++ b/rpminfo @@ -357,7 +357,7 @@ if [ $? -ne 0 -o -z $temp_prefix ]; then fi temp_prefix="$temp_prefix/" -trap "chmod -R u+rwx $temp_prefix 2>/dev/null; rm -rf $temp_prefix; exit -1" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 +trap "chmod -R u+rwx $temp_prefix 2>/dev/null; rm -rf $temp_prefix; exit -1" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 pkg_num=0 for pkg in $packages; do From 4fc95292e92a8394a02a260c7af864407e33a95b Mon Sep 17 00:00:00 2001 From: Qin Fandong Date: Dec 03 2024 01:58:08 +0000 Subject: [PATCH 2/2] Avoid triggering cleanup code through signal 0 when the rpminfo exit normally --- diff --git a/rpminfo b/rpminfo index 796a296..1dbb377 100644 --- a/rpminfo +++ b/rpminfo @@ -357,7 +357,7 @@ if [ $? -ne 0 -o -z $temp_prefix ]; then fi temp_prefix="$temp_prefix/" -trap "chmod -R u+rwx $temp_prefix 2>/dev/null; rm -rf $temp_prefix; exit -1" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 +trap "chmod -R u+rwx $temp_prefix 2>/dev/null; rm -rf $temp_prefix; exit -1" 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 18 19 20 21 22 23 24 25 26 27 28 29 30 pkg_num=0 for pkg in $packages; do @@ -386,4 +386,7 @@ if [ $installed -eq 1 ]; then done fi +trap '' 0 +chmod -R u+rwx $temp_prefix 2>/dev/null +rm -rf $temp_prefix exit 0