You can just remember it in a variable:
parent_pid = Process.pid
Process.fork do
child_pid = Process.pid
puts parent_pid, child_pid
# do stuff
exit
end
Process.wait
# 94791
# 94798
alternatively, if you need the information on the level of the parent process:
parent_pid = Process.pid
child_pid = Process.fork do
# do stuff
exit
end
Process.wait
puts parent_pid, child_pid
# 6361
# 6362