mkdumprd: check return value of subshell

Currently some functions are used in subshell to assign string to a
variable. For example:
 _mnt=$(to_mount "$1")

In this case if we call perror_exit in the subshell, subshell will exit
1, but the parent process (mkdumprd) won't exit.

So we should handle the exit code of a subshell if the subshell calls
perror_exit over a failure.

Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
WANG Chao 2013-06-26 17:52:40 +08:00 committed by Baoquan He
parent 43da5c516d
commit 791706939e

View File

@ -106,6 +106,10 @@ to_mount() {
#for non-nfs _dev converting to use udev persistent name #for non-nfs _dev converting to use udev persistent name
if [ -b "$_s" ]; then if [ -b "$_s" ]; then
_pdev="$(get_persistent_dev $_s)" _pdev="$(get_persistent_dev $_s)"
if [ $? -ne 0 ]; then
return 1
fi
else else
_pdev=$_dev _pdev=$_dev
fi fi
@ -229,6 +233,10 @@ check_size() {
return return
esac esac
if [ $? -ne 0 ]; then
perror_exit "Check dump target size failed"
fi
if [ $avail -lt $memtotal ]; then if [ $avail -lt $memtotal ]; then
echo "Warning: There might not be enough space to save a vmcore." echo "Warning: There might not be enough space to save a vmcore."
echo " The size of $2 should be greater than $memtotal kilo bytes." echo " The size of $2 should be greater than $memtotal kilo bytes."
@ -267,6 +275,9 @@ verify_core_collector() {
add_mount() { add_mount() {
if ! target_is_root "$1"; then if ! target_is_root "$1"; then
local _mnt=$(to_mount "$1") local _mnt=$(to_mount "$1")
if [ $? -ne 0 ]; then
exit 1
fi
add_dracut_mount "$_mnt" add_dracut_mount "$_mnt"
fi fi
} }
@ -530,7 +541,11 @@ do
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
perror_exit "Bad raw disk $config_val" perror_exit "Bad raw disk $config_val"
} }
add_dracut_arg "--device" "$(get_persistent_dev $config_val)" _praw=$(get_persistent_dev $config_val)
if [ $? -ne 0 ]; then
exit 1
fi
add_dracut_arg "--device" "$_praw"
check_size raw $config_val check_size raw $config_val
;; ;;
ssh) ssh)