niv has quit [Read error: Connection reset by peer]
_whitelogger has joined #ruby
_whitelogger has joined #ruby
grenierm has joined #ruby
_whitelogger has joined #ruby
dionysus69 has joined #ruby
user71 has joined #ruby
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
kerzhak has quit [Client Quit]
kerzhak has joined #ruby
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
grenierm has quit [Quit: Client closed]
grenierm has joined #ruby
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 248 seconds]
rvalue- is now known as rvalue
marc_in_space has quit [Ping timeout: 268 seconds]
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
wbooze has quit [Quit: Leaving]
grenierm has quit [Ping timeout: 240 seconds]
<depesz>
hi. i have program that does sleep(), and I want the sleep() to end when I'll send USR1 signal. I can do Signal.trap(), and it is being processed, but after signal handler, it just goes back to sleep. how can I make it stop sleeping ?
<kjetilho>
use select to sleep instead? (non-Pythonista graybeard talking)
<depesz>
[].select ?
<depesz>
not sure i follow. care to point me to doc/example ?
<kjetilho>
select.select((), (), (), 3.14) will sleep for 3.14 seconds
<depesz>
select': wrong number of arguments (given 0, expected 1..4) (ArgumentError)
<kjetilho>
you did import select first?
<depesz>
cannot load such file -- select (LoadError)
<kjetilho>
not on Unix?
<depesz>
duckduckgo-ing ruby select shows just shows array thing.
<depesz>
well, on linux.
<depesz>
sorry, i can't really stand unix.
<depesz>
too used to gnu extensiosn.
<kjetilho>
whaaa - why did I think I was in #python?
<kjetilho>
sorry!
<depesz>
that explains the confusion :)
<kjetilho>
in Ruby it is IO.select
<depesz>
thanks.
<kjetilho>
yep, seems to work the same: IO.select([],[],[], 3.14)
wbooze has joined #ruby
jhass has quit [Remote host closed the connection]
jhass has joined #ruby
gemmaro_ has quit [Ping timeout: 252 seconds]
Tempesta has quit [Quit: See ya!]
gemmaro_ has joined #ruby
<o0x1eef>
loop do
<o0x1eef>
sleep 1
<o0x1eef>
Process.kill 'SIGUSR1', Process.pid
<o0x1eef>
rescue SignalException => ex
<o0x1eef>
ex.signm == "SIGUSR1" ? break : retry
<o0x1eef>
end
<o0x1eef>
This is another way to do it
<o0x1eef>
In your case there probably wouldn't be a sleep of 1, or Process.kill - but you get the idea. :)
GreenResponse has joined #ruby
Tempesta has joined #ruby
infinityfye has joined #ruby
infinityfye has quit [Read error: Connection reset by peer]
infinityfye has joined #ruby
brokkoli_origin has quit [Remote host closed the connection]
fantazo has quit [Quit: Lost terminal]
brokkoli_origin has joined #ruby
user71 has quit [Ping timeout: 248 seconds]
Vonter has quit [Ping timeout: 260 seconds]
Vonter has joined #ruby
infinityfye has quit [Read error: Connection reset by peer]
phenom has quit [Quit: Everyone has a plan until they get punched in the face. -Mike Tyson-]
phenom has joined #ruby
oznek has joined #ruby
levitating has joined #ruby
levitating has quit [Quit: Computer exploded]
infinityfye has quit [Read error: Connection reset by peer]
cappy has joined #ruby
user71 has quit [Quit: Leaving]
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 272 seconds]
rvalue- is now known as rvalue
GreenResponse has quit [Quit: Leaving]
hightower2 has joined #ruby
casmajavi has joined #ruby
casmajavi has left #ruby [#ruby]
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
<havenwood>
A cool new thing we can do in Rubyland to say wait for a keypress is: $stdin.wait(IO::READABLE, 3.14)
<havenwood>
require 'io/wait'
<havenwood>
kjetilho: <3 select
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<o0x1eef>
I don't know, that seems like a strange round about way to do it. The sleep system call man page specifically describes the scenario put forward by depesz - it is designed to put a thread to sleep and wait for a signal to interrupt it.
kerzhak has quit [Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in]
kerzhak_ is now known as kerzhak
ih8u has joined #ruby
eddof13 has quit [Quit: eddof13]
eddof13 has joined #ruby
eddof13 has quit [Quit: eddof13]
<o0x1eef>
select, wait, etc - these are not really designed for that use-case. They're just underlying system calls that can produce EINTR like any other system call. But sleep is designed for this purpose. At least based on the info given.
<havenwood>
o0x1eef: Ruby sleep doesn't respond to SIGALRM. Maybe it should?