Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:33:57+00:00 2026-06-02T19:33:57+00:00

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

  • 0

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 up a console window, and runs as usual. If I were to hit Ctrl-C, the cleanup code will run. But if I were to close the console window, the cleanup code doesn’t run.

Is there anyway to ensure that the cleanup code would run, even in this scenario?


Side note: I am from a Java background, first time using Ruby.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:33:58+00:00Added an answer on June 2, 2026 at 7:33 pm

    Sort of. You need background processing, but unfortunately (1) under Windows IO.popen is not very reliable., and (2) even the windows “start /B” command is just going to run the code in a (shared) console.

    So…if you really need this, and you need to see the output of your program, you’ll want to install a Windows service. You could either put the critical code directly into the service or pass it the name of your executable & voila! It’ll run in the background.

    So the user would have to put some real effort into killing the app, and if you need the program’s output to go to the console, you could have the service return the necessary text.

    If you don’t need to see output, you can run the app with rubyw.exe and suppress the console. Potentially you might have your app start a second .rb file using something like start rubyw my_app.rb, depending on your requirements.

    Probably not the answer you wanted, but it should work. If you really, really need it to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some difficulties to starting a background process in Ruby. I've this code
I wrote a Ruby script that I want to run in the background repeatedly
I am using newrelic ruby agent and it is inserting some js code to
say a php script executes a ruby script in the background each time, php
Background I am interested in getting to grips with some Ruby On Rails. I've
I have a Ruby script in my Rails app that I use to load
Background: jquery 1.5.2, ruby on rails. The major issue seems to be that I'm
I have some simple Ruby scripts to run as a background job. They are
I have a Ruby 1.9 script that I want to run as a long-running
Background Perl and Ruby have the __END__ and __DATA__ tokens that allow embedding of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.