471,310 Members | 1,017 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

pipes

Hi. I'm rtying to use pipes to communicate between a python GUI and a
spawned C++ program. I prefer not to use forking because the app may
be run on windows, where forking isn't supported. Roughly what I'm
doing is:

(r,w) = os.pipe()
spawnl(P_WAIT, 'tool.exe', ' ', message, str(w))
close(w)
print os.read(r, 1000)

In c++ ,
....
int main(int argc, char** argv)
{

}

Sep 11 '07 #1
1 1432
On Mon, 10 Sep 2007 20:15:40 -0700, yagyala <mb****@phys.ksu.edu>
wrote:
>Hi. I'm rtying to use pipes to communicate between a python GUI and a
spawned C++ program. I prefer not to use forking because the app may
be run on windows, where forking isn't supported. Roughly what I'm
doing is:

(r,w) = os.pipe()
spawnl(P_WAIT, 'tool.exe', ' ', message, str(w))
close(w)
print os.read(r, 1000)

In c++ ,
...
int main(int argc, char** argv)
{

}
The 'subprocess' module provides an easier interface imo, eg:

process = subprocess.Popen('tool.exe', stdin=subprocess.PIPE,
stdout=subprocess.PIPE, universal_newlines=true)
(self.outstream, self.instream) = (process.stdout, process.stdin)

Daniel Klein
Sep 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Christian Hammers | last post: by
5 posts views Thread by Peng Yuan Fan | last post: by
5 posts views Thread by glenn.owens | last post: by
2 posts views Thread by Rudolf Bargholz | last post: by
9 posts views Thread by Hans J?rg Brinksmeyer | last post: by
4 posts views Thread by Ken Allen | last post: by
7 posts views Thread by webmaster | last post: by
1 post views Thread by Jarrod Morrison | last post: by
3 posts views Thread by ZhukovL | last post: by
7 posts views Thread by andrewb | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.