How to handle closing a console window when executing a Ruby executable packaged in OCRA?

Background:
Ruby script is packaged into an executable using OCRA 1.2.

Script is structured as follows:

begin
  <some code that runs for a while>
ensure
  <cleanup code>
end

Problem:
When I run the executable on Windows, it opens a console window and works as usual. If I manage to press Ctrl-C, the cleanup code will be launched. But if I have to close the console window, the cleanup code will not run.

In any case, to make sure the cleanup code will run, even in this scenario?


Side note: I'm from a Java background, using Ruby for the first time.

+3
source share
1 answer

. , , , (1) Windows IO.popen . (2) "start/B" Windows () .

... , , Windows. , ! .

, , , .

, rubyw.exe . , .rb, - start rubyw my_app.rb, .

, , , . .

0

All Articles