sách gpt4 ăn đã đi

ruby - quá trình nền/daemon

In lại 作者:数据小太阳 更新时间:2023-10-29 07:42:46 34 4
mua khóa gpt4 giày nike

我有一个按以下方式编码的脚本。我想将它作为后台/守护进程运行,但是一旦我启动脚本,如果我关闭它从程序运行的终端窗口终止。我需要做什么来保持程序运行

loop do

pid = fork do
..........
..........
..........
kết thúc

Process.detach(pid)
kết thúc

câu trả lời hay nhất

上面的所有答案都没有真正表明这样做有多么容易:

# Daemonize the process and stay in the current directory
Process.daemon(true)

loop do
pid = Process.fork do
# Do something funky
kết thúc

Process.waitpid(pid)

# Reduce CPU usage
sleep(0.1)
kết thúc

关于ruby - 后台/守护进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5449617/

34 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress