使目前的Python程序背景 [英] Bring the current Python program to background

查看:124
本文介绍了使目前的Python程序背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个python脚本打印信息屏幕,然后应该去后台。

A python script prints information to screen and then should go to background.

如何做到这一点从脚本本身呢?在

How to do that from within the script itself?

推荐答案

由于外壳正在等待您的进程完成,主要工艺必须终止。您可以使用 os.fork()叉掉一个子进程和 sys.exit()从父进程

Since the shell is waiting for your process to finish, the main process must terminate. You can use os.fork() to fork off a child process and sys.exit() from the parent process:

if os.fork():
    sys.exit()
# Child code goes here

这篇关于使目前的Python程序背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆