I have to run external executables from my Ruby code on Windows, for that, i'm using the
spawn
method.
Sometimes i have to run the same program very often, it executes itself very quickly then exits right away. It's not critical that i simply don't run the program for some seconds.
The problem is - sometimes i get this error :
C:/Program Files/Ruby22/lib/ruby/2.2.0/open3.rb:193:in `spawn':
Resource temporarily unavailable - identify (Errno::EAGAIN)````
My attempts to safely rescue and/or prevent the main Ruby program from crashing failed with any method i tried, even with this example :
begin
spawn( "#{cmd}" )
rescue Exception
sleep 0.3
end
i couldn't get right results.
How to rescue this case OR How to correctly thread/fork and prevent the main program from crashing?
(if possible - without tweaking the kernel / other params to increase maximum processes?).