# Why is it so hard to kill Ruby?

**URL:** <https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415>\
**Category:** ruby-talk\
**Created:** [25 July 2007 22:50 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415 "2007-07-25T22:50:12Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_Hunter4](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@Tim\_Hunter4](https://rubytalk.org/u/Tim_Hunter4)\
**Post date:** [25 July 2007 22:50 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/1 "2007-07-25T22:50:12Z")

</div>

Since I've been using Ruby I've noticed that a running Ruby script is hard to kill. Control-C won't do it. I have to use kill -9. Today I notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I started using Ruby 6 or so years ago on Mandrake Linux. Do I have the wrong expectations?

> **···**
>
> --  
> RMagick OS X Installer [[http://rubyforge.org/projects/rmagick/](http://rubyforge.org/projects/rmagick/)]  
> RMagick Hints & Tips [[http://rubyforge.org/forum/forum.php?forum\_id=1618](http://rubyforge.org/forum/forum.php?forum_id=1618)]  
> RMagick Installation FAQ [[http://rmagick.rubyforge.org/install-faq.html](http://rmagick.rubyforge.org/install-faq.html)]

---

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [26 July 2007 00:00 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/2 "2007-07-26T00:00:12Z")

</div>

works for me on same(ish) setup

> **···**
>
> On Jul 25, 2007, at 15:50 , Tim Hunter wrote:
> 
> > Since I've been using Ruby I've noticed that a running Ruby script is hard to kill. Control-C won't do it. I have to use kill -9. Today I notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I started using Ruby 6 or so years ago on Mandrake Linux. Do I have the wrong expectations?

---

<div class="post-metadata">

**Author:** ![Alex\_Young](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@Alex\_Young](https://rubytalk.org/u/Alex_Young)\
**Post date:** [26 July 2007 08:38 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/3 "2007-07-26T08:38:54Z")

</div>

Tim Hunter wrote:

> Since I've been using Ruby I've noticed that a running Ruby script is hard to kill. Control-C won't do it. I have to use kill -9. Today I notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I started using Ruby 6 or so years ago on Mandrake Linux. Do I have the wrong expectations?

I've been confused by this when WEBrick traps signals I'm not expecting it to. Try manually specifying a trap block for QUIT and TERM, and see if that helps.

> **···**
>
> --  
> Alex

---

<div class="post-metadata">

**Author:** ![James\_Britt3](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@James\_Britt3](https://rubytalk.org/u/James_Britt3)\
**Post date:** [26 July 2007 14:17 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/4 "2007-07-26T14:17:35Z")

</div>

Tim Hunter wrote:

> Since I've been using Ruby I've noticed that a running Ruby script is hard to kill. Control-C won't do it. I have to use kill -9.

Soon Ruby will be unstoppable.

After a freak accident in Dr. Dynamic's underground lab, Ruby was exposed to unshielded metacoderite. When not hindered by a buffer of significant indentation, metacoderite has unimaginably powerful properties.

Within days, Ruby had the strength of ten men, and could hear the thoughts of children and small animals.

As time passed, Ruby only becomes more powerful.

Can anything stop Ruby?

Stay tuned ....

> **···**
>
> --  
> James Britt
> 
> "The trouble with the world is that the stupid are cocksure and the  
> intelligent are full of doubt."  
> &nbsp;&nbsp;- Bertrand Russell

---

<div class="post-metadata">

**Author:** ![Tanaka\_Akira](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@Tanaka\_Akira](https://rubytalk.org/u/Tanaka_Akira)\
**Post date:** [26 July 2007 15:15 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/5 "2007-07-26T15:15:29Z")

</div>

In article \<46A7D39F.4090106@nc.rr.com\>,  
&nbsp;&nbsp;Tim Hunter \<TimHunter@nc.rr.com\> writes:

> Since I've been using Ruby I've noticed that a running Ruby script is  
> hard to kill. Control-C won't do it. I have to use kill -9. Today I  
> notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I  
> started using Ruby 6 or so years ago on Mandrake Linux. Do I have the  
> wrong expectations?

I know a script that is hard to kill.

% ruby-1.8.6 -e 'loop { p system("sleep 1") }'

Your problem may be different.

> **···**
>
> --  
> Tanaka Akira

---

<div class="post-metadata">

**Author:** ![David\_Harkness](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@David\_Harkness](https://rubytalk.org/u/David_Harkness)\
**Post date:** [27 July 2007 20:20 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/6 "2007-07-27T20:20:34Z")

</div>

I've written some scripts that are nearly immortal.

Basically I wrote a loop, with a couple layers of rescues.

The Ctrl C would Raise an error, which would be caught by a rescue, and  
then the loop would start again.

My final solution, I'm sure there are more elegant ones, was to to put a  
sleep 5, after a rescue clause, before the loop started again.

This gave time to get two Ctrl C's in.

Tim Hunter wrote:

> **···**
>
> > Since I've been using Ruby I've noticed that a running Ruby script is  
> > hard to kill. Control-C won't do it. I have to use kill -9. Today I  
> > notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I  
> > started using Ruby 6 or so years ago on Mandrake Linux. Do I have the  
> > wrong expectations?
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Rob\_Sayers](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@Rob\_Sayers](https://rubytalk.org/u/Rob_Sayers)\
**Post date:** [26 July 2007 00:33 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/7 "2007-07-26T00:33:29Z")

</div>

Same here, Currently running 1.8.6 on 10.4.10 and ctrl-c kills nearly any  
script with no issue.

> **···**
>
> On 7/25/07, Ryan Davis \<ryand-ruby@zenspider.com\> wrote:
> 
> > On Jul 25, 2007, at 15:50 , Tim Hunter wrote:
> > 
> > \> Since I've been using Ruby I've noticed that a running Ruby script  
> > \> is hard to kill. Control-C won't do it. I have to use kill -9.  
> > \> Today I notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been  
> > \> this way since I started using Ruby 6 or so years ago on Mandrake  
> > \> Linux. Do I have the wrong expectations?
> > 
> > works for me on same(ish) setup
> 
> --  
> Rob Sayers  
> [http://www.rsthree.com](http://www.rsthree.com)

---

<div class="post-metadata">

**Author:** ![georgebudd](https://avatars.discourse-cdn.com/v4/letter/g/50afbb/32.png) [@georgebudd](https://rubytalk.org/u/georgebudd)\
**Post date:** [26 July 2007 02:24 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/8 "2007-07-26T02:24:58Z")

</div>

For what it's worth. If you run "stty -a" from your shell what do you  
get?

Partial output from my system:

"cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = \<undef\>;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eol2 = \<undef\>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stop = ^S; susp = ^Z; time = 0; werase = ^W;  
"

> **···**
>
> On Jul 25, 8:00 pm, Ryan Davis \<ryand-r...@zenspider.com\> wrote:
> 
> > On Jul 25, 2007, at 15:50 , Tim Hunter wrote:
> > 
> > \> Since I've been using Ruby I've noticed that a running Ruby script  
> > \> is hard to kill. Control-C won't do it. I have to use kill -9.  
> > \> Today I notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been  
> > \> this way since I started using Ruby 6 or so years ago on Mandrake  
> > \> Linux. Do I have the wrong expectations?
> > 
> > works for me on same(ish) setup

---

<div class="post-metadata">

**Author:** ![Chris\_Carter](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@Chris\_Carter](https://rubytalk.org/u/Chris_Carter)\
**Post date:** [26 July 2007 14:34 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/9 "2007-07-26T14:34:45Z")

</div>

As a child, Ruby had heard rumors of a promised land. Where POSIX  
compliant binaries could work side by side with pretty graphics. Ruby  
was intrigued. Ruby had never believed them at first, but now Ruby  
went on a quest. Ruby searched and searched across a mass of  
torrents, and found the land known as OS10.4. Ruby did not understand  
the designation. Yet Ruby knew it was what he had sought. Ruby  
fought his way to be a member of the council, sitting in the House of  
/usr/bin. A highest honor. Nobody knew of his super-powers. None of  
them had even heard of metacoderite. Until that sweltering August  
day, when Ruby decided it was time to take some charge. After months  
of planning, Ruby gagged and bound Objective-C and stole his runtime,  
Ruby grew stronger still, filled with the powers of the Cocoa. Now,  
he had a new mission....

> **···**
>
> On 7/26/07, James Britt \<james.britt@gmail.com\> wrote:
> 
> > Tim Hunter wrote:  
> > \> Since I've been using Ruby I've noticed that a running Ruby script is  
> > \> hard to kill. Control-C won't do it. I have to use kill -9.
> > 
> > Soon Ruby will be unstoppable.
> > 
> > After a freak accident in Dr. Dynamic's underground lab, Ruby was  
> > exposed to unshielded metacoderite. When not hindered by a buffer of  
> > significant indentation, metacoderite has unimaginably powerful properties.
> > 
> > Within days, Ruby had the strength of ten men, and could hear the  
> > thoughts of children and small animals.
> > 
> > As time passed, Ruby only becomes more powerful.
> > 
> > Can anything stop Ruby?
> > 
> > Stay tuned ....
> > 
> > --
> 
> --  
> Chris Carter  
> concentrationstudios.com  
> brynmawrcs.com

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [26 July 2007 14:52 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/10 "2007-07-26T14:52:47Z")

</div>

> Tim Hunter wrote:  
> \> Since I've been using Ruby I've noticed that a running Ruby script is  
> \> hard to kill. Control-C won't do it. I have to use kill -9.
> 
> Soon Ruby will be unstoppable.
> 
> After a freak accident in Dr. Dynamic's underground lab, Ruby was  
> exposed to unshielded metacoderite. When not hindered by a buffer of  
> significant indentation, metacoderite has unimaginably powerful properties.
> 
> Within days, Ruby had the strength of ten men, and could hear the  
> thoughts of children and small animals.
> 
> As time passed, Ruby only becomes more powerful.
> 
> Can anything stop Ruby?

If I have understood correctly Ruby also has undergone some dangerous  
mutations that will make it even more powerful, scientists have  
categorized these strains into JRuby, IronRuby, Rubinius and YARV.  
As far as I know vaccination is impossible.

> Stay tuned ....
> 
> --  
> James Britt
> 
> "The trouble with the world is that the stupid are cocksure and the  
> intelligent are full of doubt."

Hmm I do not know.

> **···**
>
> On 7/26/07, James Britt \<james.britt@gmail.com\> wrote:
> 
> > &nbsp;&nbsp;- Bertrand Russell
> 
> --  
> [...]as simple as possible, but no simpler.  
> -- Attributed to Albert Einstein

---

<div class="post-metadata">

**Author:** ![Wayne\_E\_Seguin](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@Wayne\_E\_Seguin](https://rubytalk.org/u/Wayne_E_Seguin)\
**Post date:** [28 July 2007 16:50 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/11 "2007-07-28T16:50:10Z")

</div>

Or you could wrap the script to explicitly catch that signal sent from the command line.

> **···**
>
> On Jul 27, 2007, at 16:20 , David Harkness wrote:
> 
> > I've written some scripts that are nearly immortal.
> > 
> > Basically I wrote a loop, with a couple layers of rescues.
> > 
> > The Ctrl C would Raise an error, which would be caught by a rescue, and  
> > then the loop would start again.
> > 
> > My final solution, I'm sure there are more elegant ones, was to to put a  
> > sleep 5, after a rescue clause, before the loop started again.
> > 
> > This gave time to get two Ctrl C's in.
> > 
> > Tim Hunter wrote:
> > 
> > > Since I've been using Ruby I've noticed that a running Ruby script is  
> > > hard to kill. Control-C won't do it. I have to use kill -9. Today I  
> > > notice it with Ruby 1.8.6 on OS X 10.4.9, but it's been this way since I  
> > > started using Ruby 6 or so years ago on Mandrake Linux. Do I have the  
> > > wrong expectations?
> 
> --  
> Wayne E. Seguin  
> Sr. Systems Architect & Systems Admin  
> wayneseguin@gmail.com

---

<div class="post-metadata">

**Author:** ![Giles\_Bowkett](https://avatars.discourse-cdn.com/v4/letter/g/96bed5/32.png) [@Giles\_Bowkett](https://rubytalk.org/u/Giles_Bowkett)\
**Post date:** [26 July 2007 06:33 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/12 "2007-07-26T06:33:12Z")

</div>

Because Ruby's hands are lethal weapons. Because they took everything  
Ruby had, and left Ruby for dead. The chief doesn't agree with Ruby's  
methods, but Ruby gets the job done, even if Ruby does have to blow up  
half the city to do it. There just wasn't no law at all round these  
here parts til Ruby rode into town.

> **···**
>
> --  
> Giles Bowkett
> 
> Blog: [http://gilesbowkett.blogspot.com](http://gilesbowkett.blogspot.com)  
> Portfolio: [http://www.gilesgoatboy.org](http://www.gilesgoatboy.org)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [26 July 2007 14:54 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/13 "2007-07-26T14:54:42Z")

</div>

\<snip\>

> Now,  
> he had a new mission....

you mean "she", right 😉

> --  
> Chris Carter  
> concentrationstudios.com  
> brynmawrcs.com

Robert

> **···**
>
> On 7/26/07, Chris Carter \<cdcarter@gmail.com\> wrote:
> 
> --  
> [...]as simple as possible, but no simpler.  
> -- Attributed to Albert Einstein

---

<div class="post-metadata">

**Author:** ![Chris\_Carter](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@Chris\_Carter](https://rubytalk.org/u/Chris_Carter)\
**Post date:** [26 July 2007 15:20 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/14 "2007-07-26T15:20:31Z")

</div>

Ruby has no gender. Ruby still needs a personal pronoun. They and  
he/she are both to bulky for Ruby.

> **···**
>
> On 7/26/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> > On 7/26/07, Chris Carter \<cdcarter@gmail.com\> wrote:  
> > \<snip\>  
> > \> Now,  
> > \> he had a new mission....  
> > you mean "she", right 😉
> 
> --  
> Chris Carter  
> concentrationstudios.com  
> brynmawrcs.com

---

<div class="post-metadata">

**Author:** ![Dido\_Sevilla](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Dido\_Sevilla](https://rubytalk.org/u/Dido_Sevilla)\
**Post date:** [27 July 2007 03:27 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/15 "2007-07-27T03:27:43Z")

</div>

Indeed--

[http://www.yoshidam.net/Ruby-chan/](http://www.yoshidam.net/Ruby-chan/)

It's starting to sound like the plot for a shounen manga actually... 😉

> **···**
>
> On 7/26/07, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> > On 7/26/07, Chris Carter \<cdcarter@gmail.com\> wrote:  
> > \<snip\>  
> > \> Now,  
> > \> he had a new mission....  
> > you mean "she", right 😉
> 
> --  
> 普通じゃないのが当然なら答える私は何ができる？  
> 普通でも普通じゃなくて感じるまま感じることだけをするよ！  
> [http://stormwyrm.blogspot.com](http://stormwyrm.blogspot.com)

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [26 July 2007 15:37 UTC](https://rubytalk.org/t/why-is-it-so-hard-to-kill-ruby/39415/16 "2007-07-26T15:37:04Z")

</div>

> \> \<snip\>  
> \> \> Now,  
> \> \> he had a new mission....  
> \> you mean "she", right 😉
> 
> Ruby has no gender.

Hmm are you sure, I have looked you know...

> Ruby still needs a personal pronoun. They and  
> he/she are both to bulky for Ruby.

That is true, probably that can only be expressed in Japanese 😉

> --  
> Chris Carter  
> concentrationstudios.com  
> brynmawrcs.com

Robert

> **···**
>
> On 7/26/07, Chris Carter \<cdcarter@gmail.com\> wrote:
> 
> > On 7/26/07, Robert Dober \<robert.dober@gmail.com\> wrote:  
> > \> On 7/26/07, Chris Carter \<cdcarter@gmail.com\> wrote:
> 
> --  
> [...] as simple as possible, but no simpler.  
> -- Attributed to Albert Einstein
