Commit dcbb99e1 by Eric Coissac

adds a signalSpy function

parent c8f29512
......@@ -75,6 +75,9 @@ __LECABASH__contains__() {
return 1
}
#
# Check if the signal is already traped by the LECABashLib
#
__LECABASH__istrapregistred__() {
local signal="$1"
local registred=$(trap -p "$signal" \
......@@ -88,17 +91,19 @@ __LECABASH__istrapregistred__() {
fi
}
__LECABASH__registered_trap__() {
function __LECABASH__registered_trap__() {
local signal="$1"
local command=$(trap -p "$signal" \
| awk '{$NF="";\
split($0,parts,"--");\
print parts[2]}')
echo "$command"
trap -p "$signal" \
| awk '{$NF=""; \
split($0,parts,"--"); \
print parts[2]}' \
| sed -E 's/^[ '\'']+//' \
| sed -E 's/'\'' +$//'
}
__LECABASH__kill_running_command__() {
function __LECABASH__kill_running_command__() {
local signal=$1
local pid=$2
......@@ -148,3 +153,9 @@ function run() {
logdebug "Remove kill action on $fpid for $signal signal"
eval "${stackname}[${killid}]='sleep 0'"
}
function signalSpy() {
for s in $(__LECABASH__trap_signal_list__) ; do
registertrap $s loginfo Signal $s has been emited
done
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment