Hello,
I'm kinda new to ruby and have a few questions.
If i run a ruby script it can be interrupted with ^c or signals (e.g.
killall ruby"). Is it possible to catch those to do cleanup stuff before
exiting?
Whats the difference between { ... } and do ... end? Are they both
blocks? When to use what?
I'd really appreciate it if you could answer my questions, thanks.
···
--
Posted via http://www.ruby-forum.com/.
Elite Force wrote:
Hello,
I'm kinda new to ruby and have a few questions.
If i run a ruby script it can be interrupted with ^c or signals (e.g. killall ruby"). Is it possible to catch those to do cleanup stuff before exiting?
Whats the difference between { ... } and do ... end? Are they both blocks? When to use what?
I'd really appreciate it if you could answer my questions, thanks.
I would recommend that you lookup either the method Kernel#trap, the class Signal, or maybe both?
···
--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
"Yields falsehood when quined" yields falsehood when quined.
Ola Bini wrote:
Elite Force wrote:
I'd really appreciate it if you could answer my questions, thanks.
I would recommend that you lookup either the method Kernel#trap, the
class Signal, or maybe both?
--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
"Yields falsehood when quined" yields falsehood when quined.
does ctrl-c also send a signal to the process? (i guess so)
···
--
Posted via http://www.ruby-forum.com/\.
Elite Force wrote:
Ola Bini wrote:
Elite Force wrote:
I'd really appreciate it if you could answer my questions, thanks.
I would recommend that you lookup either the method Kernel#trap, the
class Signal, or maybe both?
--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
"Yields falsehood when quined" yields falsehood when quined.
does ctrl-c also send a signal to the process? (i guess so)
Yes, C-c generates a SIGINT in most common operating systems.
···
--
Ola Bini (http://ola-bini.blogspot.com)
JvYAML, RbYAML, JRuby and Jatha contributor
System Developer, Karolinska Institutet (http://www.ki.se)
OLogix Consulting (http://www.ologix.com)
"Yields falsehood when quined" yields falsehood when quined.
Ola Bini wrote:
Elite Force wrote:
does ctrl-c also send a signal to the process? (i guess so)
Yes, C-c generates a SIGINT in most common operating systems.
Okay, thank you very much!
So my last question left open is, if there's a difference between do end
and { } blocks
···
--
Posted via http://www.ruby-forum.com/\.
I think there's no difference in behaviour. There is a difference in
their precedence. {} blocks have higher precedence although usually
that doesn't make a difference. I just use {} when the block fits in a
single line with a single statement and do..end for everything else.
Pedro.
···
On 7/17/06, Elite Force <eliteforce@elitemail.org> wrote:
So my last question left open is, if there's a difference between do end
and { } blocks