The title is misleading because I am not sure I can describe my problem
at hand easily. But probably it is … I just don’t know how to solve it
yet.
Hence why I ask here.
Situation:
I wrote a very small class wrapper over this here:
sleepy_penguin - Linux I/O events for Ruby
More accurately, this here:
class SleepyPenguin::Inotify
sleepy_penguin is using inotify, which is a great idea.
So, about the code:
require “sleepy_penguin/sp”
ino = SP::Inotify.new
ino.add_watch(“/tmp”, :OPEN)
ino.each do |event|
p event.events # => [ :OPEN ]
end
This watches the directory /tmp for OPEN events.
How can I run this script in the background from within
other ruby scripts?
From the bash shell I can append &
I don’t know how to run this from a ruby script in the background yet.
It seems to “steal” stdin.
quik77
2
Marc H. wrote in post #1006402:
How can I run this script in the background from within
other ruby scripts?
The simplest way is to use the ‘daemons’ gem.
quik77
3
Thanks.
http://daemons.rubyforge.org/
I thought about it for a while. But I don’t really feel too
fondly about an API like:
Daemons.daemonize
Daemons.run(‘foo.rb’)
It seems to encourage too many different ways for me to think about.
For example, I don’t want to create a new .rb file.
I basically just want a script like:
foo.rb
To start Inotify, without the input being stolen away from me.
I suppose this can be done by reassigning $stdin or something.
Documentation isn’t ruby’s biggest strength … 
quik77
4
Marc H. wrote in post #1006470:
I thought about it for a while. But I don’t really feel too
fondly about an API like:
Daemons.daemonize
Daemons.run(‘foo.rb’)
It seems to encourage too many different ways for me to think about.
For example, I don’t want to create a new .rb file.
You don’t have to. If you get as far as point (4) in the README:
| === 4. Daemonize the currently running process
|
| …
|
| # Become a daemon
| Daemons.daemonize
I basically just want a script like:
foo.rb
To start Inotify, without the input being stolen away from me.
I suppose this can be done by reassigning $stdin or something.
Daemons will take take of disconnecting stdin/stdout/stderr for you,
although it’s not hard to close them yourself.
Documentation isn’t ruby’s biggest strength … 
I fully agree with you there 
Regards,
Brian.