# Catching system signals (UNIX)

**URL:** <https://www.ruby-forum.com/t/catching-system-signals-unix/157778>\
**Category:** Ruby\
**Created:** [January 15, 2009, 9:20am UTC](https://www.ruby-forum.com/t/catching-system-signals-unix/157778 "2009-01-15T09:20:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![voice](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f6c823/32.png) [@voice](https://www.ruby-forum.com/u/voice)\
**Post date:** [January 15, 2009, 9:20am UTC](https://www.ruby-forum.com/t/catching-system-signals-unix/157778/1 "2009-01-15T09:20:04Z")

</div>

Hello.  
I have little program (daemon), most of time it waiting with sleep  
method.  
I need to catch system’s signal SIGTERM, to terminate my program  
correctly.  
How can I do this?

Thanks.

---

<div class="post-metadata">

**Author:** ![voice](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/f6c823/32.png) [@voice](https://www.ruby-forum.com/u/voice)\
**Post date:** [January 15, 2009, 9:25am UTC](https://www.ruby-forum.com/t/catching-system-signals-unix/157778/2 "2009-01-15T09:25:42Z")

</div>

On Thu, Jan 15, 2009 at 5:19 PM, Viacheslav C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hello.  
> I have little program (daemon), most of time it waiting with sleep  
> method.  
> I need to catch system’s signal SIGTERM, to terminate my program  
> correctly.  
> How can I do this?
> 
> Thanks.

catch(‘SIGTERM’){ puts “Oh noes!” }  
END{ puts “This is the end, my friend” }

^ manveru
