In ruby standard library, popen return a object which has pid method, In eventmachine, popen return a Connection object which contain no process id information.
Demo code here:
require 'eventmachine'
def work
s = EM.popen('ls')
puts s.pid # how to get new process's pid?
end
EventMachine.run {
work
EM.stop
}
As EM.popen returns a standard a EM Connection object, you can use s.get_pid
to get the pid of the subprocess.
http://eventmachine.rubyforge.org/EventMachine/Connection.html#get_pid-instance_method