I want to run some kind of application in the background and kill its pid later.
pipe = IO.popen("firefox 'some_url' 2>&1 &") pipe.pid
This code starts firefox and returns me the pid, but unfortunately it is not firefox pid.
pipe = IO.popen("firefox") pipe.pid
This code starts firefox and returns mi pid, firefox pid. Is there a solution to start an external application and get its pid? Firefox, for example, can be any other application. I also tried with libs like: Open3 and Open4, but it seems to have the same effect. I also wonder, "$!" is a bash variable a good solution for this? Run something in the background and read "$!" What do you think?
linux ruby io popen pid
Sebastian
source share