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?
--
Jeffrey Barish 2 1992
Dennis Lee Bieber wrote: On Sat, 17 Jun 2006 11:46:29 -0600, Jeffrey Barish <je*********@earthlink.net> declaimed the following in comp.lang.python:
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...;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.*
"""
Jeffrey Barish wrote: 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? -- Jeffrey Barish import subprocess x = subprocess.Popen('nc -l 22222') x.pid
2783subprocess.Popen('taskkill %s' % x.pid)
<subprocess.Popen object at 0x0184D410> x.poll()
1 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rajarshi Guha |
last post by:
Hi,
I have some code that runs an interactive program via popen3(). The program generates
output which is then used later on. My script looks like this:
o,i,e =...
|
by: Chris Green |
last post by:
Hey folks,
I'm whipping up a quick CGI to wrap a command line app and I was a bit
suprised to not find a execl-like Popen3 style object. I don't want
to bother with the shell interpreting...
|
by: |
last post by:
This could possibly be a bug, but I don't understand it fully
so I'm posting here first. Searching the list told me other
people are having this problem too.
I have created a class which...
|
by: Ruchika |
last post by:
Hi,
I want to build an embedded Visual C++ project from the python script.
This is what I do -
evc = r'"C:\Program Files\Microsoft eMbedded C++
4.0\Common\EVC\Bin\EVC.EXE"'
proj =...
|
by: Russell E. Owen |
last post by:
I'm trying to launch an application from Python 2.3 on Windows. The
application is "ds9" (an image viewer), and is installed in C:\Program
Files\ds9\ds9
On unix I just do:
os.popen3("ds9")
and...
|
by: Jakob Simon-Gaarde |
last post by:
Follow-up on a thread from 1999 (see below)
Well now it is 2005 and the operating system I'm using is Windows
Server 2003, and I can still see that the same problem persists with:
...
|
by: John |
last post by:
Hello. Can anyone tell me how to get p.poll() or a workaound to work when
using popen3() on windows? I use python 2.3. I am trying to launch a
command window to execute a command and then check...
|
by: Pierre Rouleau |
last post by:
Hi all,
I have a consistent test case where os.popen3() hangs in Windows. The
system hangs when retrieving the lines from the child process stdout.
I know there were several reports related to...
|
by: Jonathan Mark |
last post by:
hi all...
I wrote a seemingly simple function (below) to use Popen3() and select()
to run a program and capture its exit status, stdout output, and stderr
output.
It worked fine until the box...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |