armbian-next: still fighting tee leaking under duress, and I think I won

- call `check_and_close_fd_13()` directly when `exit_with_error()` called, don't wait for trap
- store PID spawned by `do_with_logging()` under `$global_tee_pid`
- `check_and_close_fd_13()`:
  - sprinkle with `sync` to give a chance for stuff to die gracefully
  - check if `$global_tee_pid` is set and actually a running PID, if so, kill it
  - do not blindly "wait" for stuff, instead, kill it and wait for it to die -- 100% more likely to not hang ;-)
This commit is contained in:
Ricardo Pardini
2023-01-18 00:02:22 +01:00
parent ce47db1e0a
commit 62d948b1b4
3 changed files with 25 additions and 6 deletions

View File

@@ -163,6 +163,9 @@ 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
exit 43
}