Ctrl+C does not stop rails server

Showing 1-11 of 11 messages
Ctrl+C does not stop rails server Ando 3/8/12 6:25 PM
When I run "rails server" using TCS Ruby, it doesn't respond to Ctrl+C. With other versions of Ruby hitting Ctrl+C would stop the server, but with this version of Ruby it does nothing. I was wondering if this behavior is intentional.

Re: [TheCodeShop] Ctrl+C does not stop rails server Jon 3/9/12 10:18 AM

It's not intentional but it doesn't appear to be specific to TCS Ruby.

On my Win7 32bit, running `ruby script\rails server` and Ctrl+C worked for me on a new, empty rails project but `rails server` and Ctrl+C didn't work.

C:\rails-empty>ruby --version
tcs-ruby 1.9.3p134 (2012-02-19, TCS patched 2012-02-25) [i386-mingw32]

C:\rails-empty>ruby script\rails s
=> Booting WEBrick
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-09 13:10:57] INFO  WEBrick 1.3.1
[2012-03-09 13:10:57] INFO  ruby 1.9.3 (2012-02-19) [i386-mingw32]
[2012-03-09 13:10:57] INFO  WEBrick::HTTPServer#start: pid=5288 port=3000
[2012-03-09 13:11:00] INFO  going to shutdown ...
[2012-03-09 13:11:00] INFO  WEBrick::HTTPServer#start done.
Exiting


On a plain vanilla Ruby `rails server` and Ctrl+C doesn't work for me and I'm stuck at:

C:\rails-empty>ruby --version
ruby 1.9.3p163 (2012-03-06 revision 34932) [i386-mingw32]

C:\rails-empty>rails server
=> Booting WEBrick
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-03-09 13:16:33] INFO  WEBrick 1.3.1
[2012-03-09 13:16:33] INFO  ruby 1.9.3 (2012-03-06) [i386-mingw32]
[2012-03-09 13:16:33] INFO  WEBrick::HTTPServer#start: pid=4624 port=3000


Jon

Re: [TheCodeShop] Ctrl+C does not stop rails server Luis Lavena 3/9/12 10:25 AM

Haven't tried newer versions, but with thin or eventmachine used to happen to me

Will check osx and windows later today also trunk.

Sorry for top posting. Sent from mobile.

Re: [TheCodeShop] Ctrl+C does not stop rails server dmajkic 3/9/12 10:35 AM
> `rails server` and Ctrl+C didn't work.

Until this issue is resolved, just a side note that Ctrl+Break works.

Re: [TheCodeShop] Ctrl+C does not stop rails server James Cowlishaw 3/9/12 10:58 AM
On 9 Mar 2012, at 18:35, Dušan D. Majkić <dma...@gmail.com> wrote:

>> `rails server` and Ctrl+C didn't work.
>
> Until this issue is resolved, just a side note that Ctrl+Break works.

I've long had the same in 1.8.7, mongrel but IIRC 1.9.3 (webbrick) was fine.

James.

Re: [TheCodeShop] Ctrl+C does not stop rails server Jon 3/9/12 11:24 AM
> > `rails server` and Ctrl+C didn't work.
>
> Until this issue is resolved, just a side note that Ctrl+Break works.

On my Dell Studio with no Break/Pause, Ctrl+Fn+F12 seems to work with `rails s [thin]` and `ruby script\rails s [thin]`.

Re: [TheCodeShop] Ctrl+C does not stop rails server dmajkic 3/9/12 11:25 AM
> I've long had the same in 1.8.7, mongrel but IIRC 1.9.3 (webbrick) was fine.

EventMachine calls HookControlC() in emwin.cpp, which disables Ctrl+C
in app that are using em (like thin).

EM should use something like SetConsoleCtrlHandler(MyBreakHandler,
TRUE) which setes         gTerminateSignalReceived to true and gracefully
terminates.

Re: [TheCodeShop] Ctrl+C does not stop rails server Luis Lavena 3/9/12 3:47 PM


Hello,

doing "ruby script\rails server" works as expected:

https://gist.github.com/248cdd9d566d53620e86

However, all the builds (disregard of TCS or RubyInstaller) suffer the
same Ctrl+C issue of "rails server"

The culprit is Kernel#exec, which is used by "rails" script to
transfer control to the child process.

When you do "rails server" it is actually invoking exec with "ruby
script\rails server" on your application directory.

A simple script that recreates the following issue:

https://gist.github.com/2009356

Now run "ruby a.rb" and will see that no matter how much you hit
Ctrl+C, nothing happens.

I think this should be reported to Ruby-Core.
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Re: [TheCodeShop] Ctrl+C does not stop rails server Ando 3/12/12 1:49 AM
Thanks for taking the time to figure this out. Sure, go ahead and report it :) 

On Saturday, March 10, 2012 12:47:45 AM UTC+1, Luis Lavena wrote:
Re: [TheCodeShop] Ctrl+C does not stop rails server Luis Lavena 3/12/12 7:08 AM
On Mon, Mar 12, 2012 at 5:49 AM, Ando <aceme...@gmail.com> wrote:
> Thanks for taking the time to figure this out. Sure, go ahead and report it
> :)

Reported:

http://bugs.ruby-lang.org/issues/6131

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Re: [TheCodeShop] Ctrl+C does not stop rails server Jon 3/12/12 7:08 AM
> Thanks for taking the time to figure this out. Sure, go ahead and report it
> :)

I think Luis (a ruby-core committer) was suggesting that (a) you've discovered a real issue, and (b) you should report this as a bug https://bugs.ruby-lang.org/

FYI, a related reason (performance) why you might want to use `ruby script\rails`  http://jstorimer.com/2011/12/20/rails-and-exec.html

Jon

---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
twitter: @jonforums