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

  • Home
  • SEARCH
  • 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 7771871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:45:17+00:00 2026-06-01T16:45:17+00:00

I started learn Ruby. I tried to work with WEBrick server. After ruby index.rb

  • 0

I started learn Ruby. I tried to work with WEBrick server. After ruby index.rb command server starts. And how to stop it? I tried Ctrl+c, Ctrl+X and other. It still working. Then I pushed Ctrl+Z. Bash said: [1]+ Stopped ruby index.rb. But process is still working, and using my port, that need for server. I can kill it only from System Monitor.

What command I need to user in bash to kill index.rb process??

When I user Ctrl+C, there is error:

[2012-04-09 19:44:10] ERROR Interrupt: 
/usr/lib/ruby/1.8/webrick/server.rb:91:in `select'

P.S. Application is very simple (from WikiBooks):

   require 'webrick'
server = WEBrick::HTTPServer.new(:Port=>8080)
server.mount_proc('/'){ |req, resp|
    File.open('notepad.txt', 'w'){ |f| f.write(req.query["text"]) } if req.query["text"]
    resp['Content-Type'] = 'text/html'
    resp.body = %& <html><body><center><form method="post">
        <textarea name="text" rows="4" cols="40">#{IO.read('notepad.txt')}</textarea><br/>
        <input type="submit" name="update" value="save"/>
        </form></center></body></html></nowiki>& 
}
  • 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-01T16:45:18+00:00Added an answer on June 1, 2026 at 4:45 pm

    You can always kill your process by specifying a PID.

    To get the pid from your server process you can use

    $ ps a | grep ruby

    Where PID is the first column, after that use: $ kill -9 <YOUR_PID> to kill the process.

    Your server is not catching SIGINT, that’s why you can’t stop it with Ctrl+C.

    Change your script to this

    require 'webrick'
    
    server = WEBrick::HTTPServer.new(:Port=>8080)
    
    trap 'INT' do server.shutdown end
    
    server.mount_proc('/'){ |req, resp|
        File.open('notepad.txt', 'w'){ |f| f.write(req.query["text"]) } if req.query["text"]
        resp['Content-Type'] = 'text/html'
        resp.body = %& <html><body><center><form method="post">
            <textarea name="text" rows="4" cols="40">#{IO.read('notepad.txt')}</textarea><br/>
            <input type="submit" name="update" value="save"/>
            </form></center></body></html></nowiki>& 
    }
    
    server.start
    

    And enjoy Ctrl+C!

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

Sidebar

Related Questions

I just started to learn Ruby and as a .Net developer, I'm wondering if
I have just started to learn Ruby and got a good take on the
I've started to learn Ruby recently, and was wondering about which version to learn.
After learning power of Rails framework, I have started learning ruby. In Ruby, I
I started to learn using Instrument, but I cannot figure it out. After I
About half a year ago, when I started to learn Ruby and Rails, I
I've just started playing around in Haskell. After years of Ruby, I got used
I've wanted to learn Ruby for some time and even started to learn a
I have recently started to learn Ruby. I know that Ruby is a interpreted
I started to learn ruby programming language, i want to output my ruby scripts

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.