Returning data from forked processes

后端 未结 7 868
别那么骄傲
别那么骄傲 2020-12-08 14:37

If I do

Process.fork do 
  x 
end 

how can I know what x returned (e.g. true/fase/string) ?

(Writing to a file/database is not an

7条回答
  •  时光取名叫无心
    2020-12-08 15:21

    According to the documentation:

    If a block is specified, that block is run in the subprocess, and the subprocess terminates with a status of zero.

    So if you call it with a block, it returns 0. Otherwise, it functions basically the same as the fork() system call on Unix (the parent receives the PID of the new process, the child receives nil).

提交回复
热议问题