【问题标题】:Launch subprocess in Ruby and continue execution of script在 Ruby 中启动子进程并继续执行脚本
【发布时间】:2020-02-02 13:17:24
【问题描述】:

我想在 Ruby 中启动一个子进程,具体来说是一个外部 .exe 文件(我在 Windows 环境中工作)。我不想阻塞 Ruby 脚本,所以我想在子进程运行时返回到脚本的下一行。 Ruby 脚本甚至可以在子进程完成之前完成。

有什么办法吗?我试过 exec()、fork()、spawn()、system()... 但不能让它正常工作。

【问题讨论】:

    标签: ruby windows shell command-line subprocess


    【解决方案1】:

    你可以使用Thread:

    Thread.new { <your logic here> }

    Thread 上定义了一堆帮助方法,可让您监视和操作线程。

    【讨论】:

      猜你喜欢
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 2013-02-16
      • 2019-07-30
      • 1970-01-01
      • 2019-01-10
      • 1970-01-01
      • 2013-12-08
      相关资源
      最近更新 更多