mirror of
https://github.com/openwrt/packages.git
synced 2025-12-24 08:28:20 +04:00
modemmanager: fix pending mmcli calls for ModemManager-monitor script
If the ModemManager is stopped via '/etc/init.d/modemmanager', mmcli calls always remain in the process list. This is because the ModemManager-monitor call is not terminated properly, as the kill signals are not handled correctly in the startup script for mmcli. To fix this, the signal handling is refactored. Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
committed by
Florian Eckert
parent
5c203c36d5
commit
6c8ad9f02b
@@ -6,9 +6,10 @@
|
||||
|
||||
trap_with_arg() {
|
||||
func="$1" ; shift
|
||||
pid="$1" ; shift
|
||||
for sig ; do
|
||||
# shellcheck disable=SC2064
|
||||
trap "$func $sig" "$sig"
|
||||
trap "$func $sig $pid" "$sig"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ func_trap() {
|
||||
mm_monitor_cache_remove "$object"
|
||||
done < ${MODEMMANAGER_MONITOR_CACHE}
|
||||
|
||||
kill "-${1}" "$CHILD" 2>/dev/null
|
||||
kill "-${1}" "$2" 2>/dev/null
|
||||
}
|
||||
|
||||
mm_monitor_get_sysfspath() {
|
||||
@@ -116,8 +117,6 @@ main() {
|
||||
local step=1
|
||||
local mmrunning=0
|
||||
|
||||
trap_with_arg func_trap INT TERM KILL
|
||||
|
||||
mkdir -p "${MODEMMANAGER_RUNDIR}"
|
||||
chmod 0755 "${MODEMMANAGER_RUNDIR}"
|
||||
|
||||
@@ -140,16 +139,18 @@ main() {
|
||||
return
|
||||
}
|
||||
|
||||
/usr/bin/mmcli -M | {
|
||||
sh -c "echo \$\$; exec /usr/bin/mmcli -M" | {
|
||||
read -r monitor_pid
|
||||
trap_with_arg func_trap "$monitor_pid" SIGINT SIGTERM SIGKILL
|
||||
local line
|
||||
while read -r line; do
|
||||
mm_log "debug" "Monitor cache line: ${line}"
|
||||
mm_monitor_cache "$line"
|
||||
done
|
||||
} &
|
||||
CHILD="$!"
|
||||
|
||||
wait $CHILD
|
||||
child="$!"
|
||||
trap_with_arg func_trap "$child" SIGINT SIGTERM SIGKILL
|
||||
wait $child
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user