How to fire and forget a subprocess?

前端 未结 5 1288
深忆病人
深忆病人 2021-01-31 04:28

I have a long running process and I need it to launch another process (that will run for a good while too). I need to only start it, and then completely forget about it.

5条回答
  •  后悔当初
    2021-01-31 05:12

    Detaching $$ wasn't right. From p. 348 of the Pickaxe (2nd Ed):

    $$ Fixnum The process number of the program being executed. [r/o]

    This section, "Variables and Constants" in the "Ruby Language" chapter, is very handy for decoding various ruby short $ constants - however the online edition (the first

    So what you were actually doing was detaching the program from itself, not from its child. Like others have said, the proper way to detach from the child is to use the child's pid returned from fork().

提交回复
热议问题