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.
Elite F. 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 B. (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 B. wrote:
Elite F. 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 B. (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)
Ola B. wrote:
Elite F. 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
Elite F. wrote:
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 B. (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.
On 7/17/06, Elite F. [email protected] wrote:
So my last question left open is, if there’s a difference between do end
and { } blocks
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.