pipes

Y

yagyala

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)
{

}
 
D

Daniel Klein

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top