【发布时间】:2015-10-11 13:38:08
【问题描述】:
pid = Process.fork
#sleep 4
Process.daemon nil, true
if pid.nil? then
job.exec
else
#Process.detach(pid)
end
Process.fork 返回的pid 在Process.daemon(nil, true) 运行后立即更改。有没有办法保存/跟踪随后被守护的分叉子进程的 pid?
我想从父进程中知道子进程的 pid。到目前为止,我能够与 pid 通信的唯一方法是通过IO.pipe 将Process.pid 写入 IO#write,然后使用父级的 IO#read 读取它。不太理想
【问题讨论】:
标签: ruby process multiprocessing fork daemon