I need to run console command in ruby (in my case to start Gvim), get PID of Gvim and kill that process in a few seconds.
If I do the following - it gives me PID of parent process, but I need somehow to find out the PID of Gvim.
IO.popen("gvim file_name_to_open" { |gvim|
puts gvim.pid
}
If I do the following, it just starts Gvim and does nothing more (I need Gvim process to be killed).
pid = Process.spawn("gvim", "file_name_to_open")
sleep(5)
Process.kill(9, pid)
Process.wait pid
What am I doing wrong?