How can I check from Ruby whether a process with a certain pid is running?

前端 未结 9 2071
眼角桃花
眼角桃花 2021-01-30 16:18

If there is more than one way, please list them. I only know of one, but I\'m wondering if there is a cleaner, in-Ruby way.

9条回答
  •  感动是毒
    2021-01-30 16:57

    You can try using

    Process::kill 0, pid
    

    where pid is the pid number, if the pid is running it should return 1.

提交回复
热议问题