Python:fork,pipe和exec [英] Python: fork, pipe and exec

查看:230
本文介绍了Python:fork,pipe和exec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在python应用程序中执行一个程序,它会在后台运行,但最终会出现在前台.

I want to execute a program in a python application, it will run in the background but eventually come to the foreground.

使用GUI进行交互.但是控件是通过stdin和stdout上的控制台提供的.我希望能够使用应用程序的GUI对其进行控制,所以我的第一个想法是:

A GUI is used to interact with it. But controls are offered via a console on stdin and stdout. I want to be able to control it using my application's GUI, so my first idea was:

  • 在父级中使用dup2 stdin和stdout以便访问它们
  • 执行孩子

这在python中容易实现吗?有其他方法可以实现我想要的东西吗?

Is this easily implementable in python and how? Are there alternative ways to achieve what I want, what would that be?

推荐答案

使用标准的Python子流程模块,这相当容易:

This is reasonably easy using the standard Python subprocess module:

http://docs.python.org/py3k/library/subprocess.html

这篇关于Python:fork,pipe和exec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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