Clueless: piping between 2 non-python processes

Michael Lehmeier m_lehmeier at gmx.de
Sat Oct 25 14:16:33 EDT 2003


Hi, I have a problem.

I have written a big python script with a simple passage like that:

while 1 :
   if os.system("A | B") == 256 :
      sys.exit(0)

A is a streaming application, B an encoding application.
Both are not python.
Occasionally A terminates and the command is executed again.
If it is stopped by a SIGINT, os.system returns 256 and the script ends.

The problem is: B can also terminate by itself.
Whenever this happens, A continues to happily pipe data to a
non-existant B until eternity or A stops.

So I wanted to start A and B as fork, but all solutions to create a pipe
between them seem to demand that at least one of the two processes is in
python itself.
Or maybe I just understood it wrong.

So the basic problem is:
- create two processes A and B
- pipe from A to B
- terminate A when B ends

Can anybody help?
Thanks!




More information about the Python-list mailing list