armbian-next: still fighting tee leaking: now I think I won, again

- avoid using the "last resort, use lazy umount" by killing tee_pid _and descendants_ before hand. Works!
- introduce `get_descendants_of_pid_array()` using recursive trick to get all descendants
- do not `unset CURRENT_LOGFILE` -- during `logging_error_show_log()` (from SHOW_LOG=no days)
  - do `unset CURRENT_LOGFILE` immediately before processing logs -- although it magically survives. mysteries of traps in bash...
- `declare -g` instead of `export` for `start_logging_section()`
- don't `check_and_close_fd_13()` in `run_cleanup_handlers()`
- do run `check_and_close_fd_13()`, but only after archiving the old logs (in logging trap!)
- add a default error for unhandled TRAP's -- of which should be done
- fix reset of `global_tee_pid=0` in section-logging
This commit is contained in:
Ricardo Pardini
2023-01-18 20:22:39 +01:00
parent c1100fa461
commit bf3f346bee
6 changed files with 78 additions and 29 deletions

View File

@@ -78,6 +78,9 @@ function main_trap_handler() {
# Run the cleanup handlers, always.
run_cleanup_handlers || true
;;
*)
display_alert "main_trap_handler" "Unknown trap type '${trap_type}'" "err"
;;
esac
}
@@ -163,8 +166,7 @@ function exit_with_error() {
#exec {FD}> /var/lock/armbian-debootstrap-losetup
#flock -u "${FD}"
# let's try early to close tee/sed and fd 13 which might be opened if this happened in a logging section
check_and_close_fd_13
# do NOT close the fd 13 here, otherwise the error will not be logged to logfile...
exit 43
}