You can do something like this:
Thread.new do
begin
Process.wait Process.spawn 'find /oeinfsroif'
raise unless $?.exitstatus == 0
rescue
retry
end
end.join
To manage the number of attempts before the failing:
Thread.new do
max_attempts = 10
attempts = 0
begin
Process.wait Process.spawn 'find /oeinfsroif'
raise unless $?.exitstatus == 0
rescue
attempts += 1
attempts < max_attempts ? retry : raise
end
end.join
Output:
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
find: `/oeinfsroif': No such file or directory
rb:6:in `block in <main>': unhandled exception