Now I need to create a process with a name(the process is an instance of
I can create a webrick instance using following command,(this is not a
blocking call, it returns immediately…thats what I want)
input, out, err, @pid = Open4.popen4(‘D:\ruby\bin\ruby
C:\InstantRails\rails_apps\app1\script\server -p 3002’)
Now at later point of time I would like to kill this process which I can
ofcourse do using
It may very well happen that process was killed externally, hence in
case I am first finding out if process with @pid is still alive by
Process.kill(0,@pid) (it gives an error it the process is not alive,
My assumption in above case is that the webrick instance I had created
earlier using popen4 method is still running with @pid; it may very well
happen that webrick instance was killed externally and @pid was taken up
some other process; this will result in killing of a innocent process.
I was thinking if I could assign a name to a process and then later on
killing, verify the name, then that would solve the problem.
But how do I assign a name to a process while creating a process using
popen4 method and then how do I find the pid of a process by name.
Help is appreciated!