“叉子和退出”需要? [英] "fork and exit" needed?
问题描述
嗨
我是Python的新手,并希望重写这个Perl脚本
与Asterisk PBX一起运行:
http://www.voip-info .org / wiki / view / Asterisk + NetCID
任何人都知道这些行是否必要,为什么以及他们的
替代品是什么Python?
-------
打开STDOUT,''> / dev / null'';
分叉和退出;
-------
谢谢。
Vincent Delporte写道:
嗨
我是Python的新手,并希望重写这个Perl脚本
与Asterisk PBX一起运行:
http://www.voip-info.org/wiki/view/Asterisk+NetCID
任何人都知道这些行是否必要,为什么以及他们在Python中的替代品是什么?
open STDOUT,''> / dev / null'';
将stdout重新定义为/ dev / null的打开文件对象,或者将
脚本作为script.py> /运行dev / null"
fork and exit;
类似于:
如果os.fork():
sys.exit( 0)
告诉父母在孩子继续跑步时退出叉子。
这些都是成为守护进程的步骤(comp.unix。程序员
FAQ,虽然倾向于C,但解释了为什么其中一些步骤需要
。
在< 8o ******************************** @ 4ax.com> ;, Vincent Delporte写道:
任何人都知道这些行是否必要,为什么以及他们在Python中使用什么?b $ b替代品?
-------
打开STDOUT,''> / dev / null'';
sys.stdout = open(os.devnull,''w'')
Ciao,
Marc''BlackJack''Rintsch
Marc''BlackJack''Rintsch< bj **** @ gmx.netwrote:
< blockquote class =post_quotes>
In< 8o ******************************** @ 4ax。 com>,Vincent Delporte写道:
任何人都知道这些行是否必要,为什么以及他们在Python中使用的是什么?b $ b替代品?
打开STDOUT,''> / dev / null'';
sys.stdout = open(os.devnull,''w'')
这个没有没有预期的效果
如果你运行这个
导入操作系统,系统,时间
打印os.getpid()
sys.stdout = open(os.devnull,''w'')
time.sleep(60)
>
它打印它的pid。
Hi
I''m a Python newbie, and would like to rewrite this Perl scrip
to be run with the Asterisk PBX:
http://www.voip-info.org/wiki/view/Asterisk+NetCID
Anyone knows if those lines are necessary, why, and what their
alternative is in Python?
-------
open STDOUT, ''>/dev/null'';
fork and exit;
-------
Thank you.
Vincent Delporte wrote:Hi
I''m a Python newbie, and would like to rewrite this Perl scrip
to be run with the Asterisk PBX:
http://www.voip-info.org/wiki/view/Asterisk+NetCID
Anyone knows if those lines are necessary, why, and what their
alternative is in Python?
open STDOUT, ''>/dev/null'';Either redefine stdout to an open file object for /dev/null or run the
script as "script.py >/dev/null"
fork and exit;something like:
if os.fork():
sys.exit(0)
Tells the parent to exit after the fork while the child keeps running.
These are both steps in becoming a daemon (the comp.unix.programmer
FAQ, while skewed toward C, explains why some of these steps are
needed).
In <8o********************************@4ax.com>, Vincent Delporte wrote:
Anyone knows if those lines are necessary, why, and what their
alternative is in Python?
-------
open STDOUT, ''>/dev/null'';sys.stdout = open(os.devnull, ''w'')
Ciao,
Marc ''BlackJack'' Rintsch
Marc ''BlackJack'' Rintsch <bj****@gmx.netwrote:In <8o********************************@4ax.com>, Vincent Delporte wrote:
Anyone knows if those lines are necessary, why, and what their
alternative is in Python?
open STDOUT, ''>/dev/null'';
sys.stdout = open(os.devnull, ''w'')This doesn''t have the desired effect
If you run this
import os,sys,time
print os.getpid()
sys.stdout = open(os.devnull, ''w'')
time.sleep(60)
It prints its pid.
这篇关于“叉子和退出”需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!