Re: terminating an inactive process
if you have pywin32 then check out a download from MS download called script-o-matic2. it will write some boilerplate code that is usefull for killing processes. its wmi based but works nicely. i have a script that i run on my home computer if you want a sample. -- http://mail.python.org/mailman/listinfo/python-list
Re: terminating an inactive process
[Earl Eiland wrote] I'm running a PyWin program that executes another program using subprocess.Popen(). Unfortunately, this other program isn't well behaved, and frequently terminates without terminating its process. After this happens enough times, all my memory is tied up, and the machine crashes. Using subprocess.poll(), I can keep my program from hanging, by timing out the process, and starting anew. This still leaves the previous process hogging memory. How do I kill the old process in Windows? You might be able to use or borrow code from my process.py module. process.py is very similar to Python 2.4's subprocess. It provides a ProcessOpen class (similar to subprocess' Popen). A ProcessOpen instance has wait() and kill() methods that work fine on Windows. Under the hood they are using the Win32 API WaitForSingleObject() and TerminateProcess() functions. http://starship.python.net/~tmick/ Yes, I haven't updated process.py in a while. :) It works fine with Python 2.3 and 2.4 (despite only saying Python 2.2 there). It *does* rely on the PyWin32 extensions being installed with you Python installation -- which you'll already have if you use ActivePython or which you can install separately from here: http://sourceforge.net/project/showfiles.php?group_id=78018 Cheers, Trent -- Trent Mick [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
terminating an inactive process
I'm running a PyWin program that executes another program using subprocess.Popen(). Unfortunately, this other program isn't well behaved, and frequently terminates without terminating its process. After this happens enough times, all my memory is tied up, and the machine crashes. Using subprocess.poll(), I can keep my program from hanging, by timing out the process, and starting anew. This still leaves the previous process hogging memory. How do I kill the old process in Windows? Earl -- http://mail.python.org/mailman/listinfo/python-list
Re: terminating an inactive process
i use this to open/close netscape as it also doesnt like to close all the time. its a WMI script but easiely edited. check out script-o-matic from ms-downloads , it outputs python code as well as others. ## strComputer = . Set objWMIService = GetObject(winmgmts:\\ strComputer \root\cimv2) Set colItems = objWMIService.ExecQuery(Select * from Win32_Process,,48) For Each objItem in colItems strProcess = Ucase(objItem.Name) If strProcess = NETSCP.EXE Then objItem.Terminate() End If Next '- MyVar = MsgBox (Do you want to start Netscape Mail and News chr(13) chr(13) Any Zombie processes have been exorcised from the machine already. chr(13) chr(13) , 308, Warning!) Set objWMIService = Nothing Set colItems = Nothing If MyVar = 7 Then Wscript.Quit Else sExecStr = C:\Program Files\Netscape\Netscape\Netscp.exe -mail Dim oShell, obj Set oShell = WScript.CreateObject (WSCript.shell) Set obj = oShell.exec(sExecStr) Set oShell = Nothing Set obj = Nothing End If ' MyVar = MsgBox (Click to close Netscape) strComputer = . Set objWMIService = GetObject(winmgmts:\\ strComputer \root\cimv2) Set colItems = objWMIService.ExecQuery(Select * from Win32_Process,,48) For Each objItem in colItems strProcess = Ucase(objItem.Name) If strProcess = NETSCP.EXE Then objItem.Terminate() End If Next Set objWMIService = Nothing Set colItems = Nothing -- http://mail.python.org/mailman/listinfo/python-list