Popen3 on Windows

J

Jeffrey Barish

I have an application that has been working fine on Linux, but now I need to
port it to Windows XP. The program uses Popen3 to run another program. I
use Popen3 so that I can access the pid attribute, which I use to kill the
auxiliary program when necessary. Popen3 does not exist on Windows. I see
os.popen2 and os.popen3, but they provide only file objects for stdin,
stdout, and stderr so I don't see a way to kill the auxiliary program that
I start. Is there a way to do this on Windows?
 
D

Dennis Lee Bieber

I start. Is there a way to do this on Windows?

There is no safe, easy, way to reliably kill a program on Windows...

Hmmm, there's one I hadn't know about...
http://www.tech-recipes.com/windows_tips446.html
Ah, not supplied in WinXP Home (my desktop is Pro)

Seems besides taskkill, there is also a tskill with different
arguments...

The M$ response
http://support.microsoft.com/default.aspx?scid=KB;en-us;178893&


Granted, these don't explain how to get the PID in the first place
from Python.

If possible, try using the subprocess module... It seems to have a
PID attribute.

--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
S

SuperHik

Dennis said:
There is no safe, easy, way to reliably kill a program on Windows...

Hmmm, there's one I hadn't know about...
http://www.tech-recipes.com/windows_tips446.html
Ah, not supplied in WinXP Home (my desktop is Pro)

Seems besides taskkill, there is also a tskill with different
arguments...

The M$ response
http://support.microsoft.com/default.aspx?scid=KB;en-us;178893&


Granted, these don't explain how to get the PID in the first place
from Python.

If possible, try using the subprocess module... It seems to have a
PID attribute.
from http://docs.python.org/dev/lib/module-subprocess.html
"""
16.1 subprocess -- Subprocess management

New in version 2.4.

The subprocess module allows you to spawn new processes, connect to
their input/output/error pipes, and obtain their return codes. This
module *intends to replace* several other, older modules and functions,
such as:

os.system
os.spawn*
os.popen*
popen2.*
commands.*
"""
 
R

reed

Jeffrey said:
I have an application that has been working fine on Linux, but now I need to
port it to Windows XP. The program uses Popen3 to run another program. I
use Popen3 so that I can access the pid attribute, which I use to kill the
auxiliary program when necessary. Popen3 does not exist on Windows. I see
os.popen2 and os.popen3, but they provide only file objects for stdin,
stdout, and stderr so I don't see a way to kill the auxiliary program that
I start. Is there a way to do this on Windows?
1
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top