0032-base-files-upgrade-don-t-loop-forever-trying-to-kill-processes.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Thu, 13 Jul 2017 00:19:32 +0200
  3. Subject: base-files: upgrade: don't loop forever trying to kill processes
  4. When processes don't die on SIGKILL (usually because of kernel bugs), it's
  5. better to give up instead of looping forever.
  6. upgraded will trigger a reboot in this case (and if this fails, a hardware
  7. watchdog will eventually time out and reset the system, if present).
  8. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  9. diff --git a/package/base-files/files/lib/upgrade/stage2 b/package/base-files/files/lib/upgrade/stage2
  10. index bdbb8926643287f48a4ae62c5d1d4b4a29130859..097ad63adfecdd70019acaa5b652d2056e774c3f 100755
  11. --- a/package/base-files/files/lib/upgrade/stage2
  12. +++ b/package/base-files/files/lib/upgrade/stage2
  13. @@ -87,6 +87,8 @@ switch_to_ramfs() {
  14. }
  15. kill_remaining() { # [ <signal> [ <loop> ] ]
  16. + local loop_limit=10
  17. +
  18. local sig="${1:-TERM}"
  19. local loop="${2:-0}"
  20. local run=true
  21. @@ -117,8 +119,15 @@ kill_remaining() { # [ <signal> [ <loop> ] ]
  22. [ $loop -eq 1 ] && run=true
  23. done
  24. +
  25. + let loop_limit--
  26. + [ $loop_limit -eq 0 ] && {
  27. + echo
  28. + echo "Failed to kill all processes."
  29. + exit 1
  30. + }
  31. done
  32. - echo ""
  33. + echo
  34. }