diff --git a/Library/Homebrew/unpack_strategy/dmg.rb b/Library/Homebrew/unpack_strategy/dmg.rb index b18cb0c835223c1674df4d158ed4e1abc7adeddd..65928d05db0e1fcc1442737c3fae1b2ca6ef336e 100644 --- a/Library/Homebrew/unpack_strategy/dmg.rb +++ b/Library/Homebrew/unpack_strategy/dmg.rb @@ -39,14 +39,25 @@ module UnpackStrategy end def bom - # rubocop:disable Style/AsciiComments - # We need to use `find` here instead of Ruby in order to properly handle - # file names containing special characters, such as 鈥渆鈥� + 鈥溌粹€� vs. 鈥溍┾€�. - # rubocop:enable Style/AsciiComments - result = system_command("find", args: [".", "-print0"], chdir: self, print_stderr: false) - - odebug "BOM `find` exit code: #{result.exit_status}" - odebug "BOM `find` output:", result.merged_output + tries = 0 + result = loop do + # rubocop:disable Style/AsciiComments + # We need to use `find` here instead of Ruby in order to properly handle + # file names containing special characters, such as 鈥渆鈥� + 鈥溌粹€� vs. 鈥溍┾€�. + # rubocop:enable Style/AsciiComments + r = system_command("find", args: [".", "-print0"], chdir: self, print_stderr: false) + tries += 1 + + odebug "BOM `find` output (try #{tries}):", r.merged_output + + break r unless r.stderr.match?(/Interrupted system call/i) + + raise "BOM `find` was interrupted." if tries >= 3 + + odebug "BOM `find` failed due to interrupt, retrying..." + end + + raise "BOM `find` took #{tries} tries." if tries > 1 result .stdout