On Thu, 11 Jan 2007, Thiago Jackiw wrote:

>> > The scenario (for test purposes) I'm trying to accomplish when running
>> > rake on a new Rakefile is:
>> >
>> > 1) start a java server (which doesn't have an option to 'daemonize'
>> > it) and get its pid
>> > 2) interact with the server by sending things or accessing it
>> > 3) stop the server

you don't have an easy choice.  if you want to interact you'll want to be unix
specifc.

how do you want to interact?  via stdin/stdout?  does the process need to be a
daemon or should it depend on the process controlling it also existing?  is
the controlling process transient or permanent?

>> > I've tried using IO's popen, fork, thread, even sending the server to
>> > /dev/null when starting it but none of them work as I expected.

does the server allow itself to run without a tty?  some programs don't and
then you'll need to use the ruby pty lib.  this would also limit you to unix.

> Once the
>> > server (step 1) starts it just hangs in there, not letting the following
>> > steps to run.

is it waiting for input?

> But if I kill the server (control+c) the step 2 tries to
>> > run and fails because the server is no longer running.

makes sense...


regards.

-a
-- 
in the practice of tolerance, one's enemy is the best teacher.
- the dalai lama