[Pm-utils] [PATCH 6/6] Fix running non-core hooks in parallel.
Victor Lowther
victor.lowther at gmail.com
Sun May 11 18:44:05 PDT 2008
We need to wait for all the hooks to finish running, so explicitly
create a subshell to actually run the hooks in instead of relying
on the while read loop to implicitly create one.
---
pm/pm-functions.in | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/pm/pm-functions.in b/pm/pm-functions.in
index b101f97..f82d85c 100644
--- a/pm/pm-functions.in
+++ b/pm/pm-functions.in
@@ -183,27 +183,29 @@ run_some_hooks()
local hook_coa="$2"
local hook_order="$3"
shift; shift; shift
- get_${hook_coa}_hooks $hook_type $hook_order |while read base; do
- if [ -f "$syshooks/$base" ]; then
- hook="$syshooks/$base"
- elif [ -f "$phooks/$base" ]; then
- hook="$phooks/$base"
- else
- log "$base is not a hook at all!"
- continue
- fi
- log -n "${hook} $@: "
- hook_ok "$hook" && {
- if [ "$hook_coa" = "core" ]; then
- "${hook}" "$@"
- hook_exit_status $?
+ get_${hook_coa}_hooks $hook_type $hook_order | (
+ while read base; do
+ if [ -f "$syshooks/$base" ]; then
+ hook="$syshooks/$base"
+ elif [ -f "$phooks/$base" ]; then
+ hook="$phooks/$base"
else
- "${hook}" "$@" &
- echo "running in background."
+ log "$base is not a hook at all!"
+ continue
fi
- }
- done
+ log -n "${hook} $@: "
+ hook_ok "$hook" && {
+ if [ "$hook_coa" = "core" ]; then
+ "${hook}" "$@"
+ hook_exit_status $?
+ else
+ "${hook}" "$@" &
+ echo "running in background."
+ fi
+ }
+ done
[ "$hook_coa" = "core" ] || wait
+ )
}
# Run all applicable hooks, logging success and failure as we go.
--
1.5.4.3
More information about the Pm-utils
mailing list