473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to terminate a process on win32?

Hi,

I am developing two app on Windows, one is a GUI using wxPython and the other is like a daemon process. The GUI app will have a start/stop button to control the excution of the daemon. While I know how to use os.popen2() to start my daemon, I can't figure out a way to stop it 'nicely'... Is there anything that I can do?

Regards,

-- Wong

Jul 18 '05 #1
4 2368
Joe Wong wrote:
Hi,

I am developing two app on Windows, one is a GUI using wxPython and the
other is like a daemon process. The GUI app will have a start/stop
button to control the excution of the daemon. While I know how to use
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?

Regards,

-- Wong


You can use the win32process.TerminateProcess function to kill a
process... see the win32 docs

David
Jul 18 '05 #2
"Joe Wong" <jo*****@mango.cc> wrote:
I am developing two app on Windows, one is a GUI using wxPython and the
other is like a daemon process. The GUI app will have a start/stop
button to control the excution of the daemon. While I know how to use
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


It depends on your OS. I remember once upon a time, in order to kill
processes sucessfully for all Windows platforms (from Win98 to NT to
2000/XP), I had to resort to using tlist.exe and kill.exe, plus
w9xpopen.exe for pipes in Windows 98. It was kind of annoying... I
seem to remember short name and long names were problem, too. At the
end, the killing logic became a small program in itself!

regards,

Hung Jung
Jul 18 '05 #3
"Joe Wong" <jo*****@mango.cc> wrote in message news:<ma*************************************@pyth on.org>...
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


Mark Hammond's Python for Windows extensions includes a demonstration
of killing processes on Windows:

On my PC:
C:\Python23\Lib\site-packages\win32\scripts\killProcName.py

Python for Windows extensions:
http://starship.python.net/crew/mhammond/
https://sourceforge.net/projects/pywin32/

Regards, Myles.
Jul 18 '05 #4
But calling TerminateProcess will stop the application right away. I need
someway that the process being killed get notified and thus to carry out
some procedure before shut down. On Linux, I can use kill(pid, signum) to
achive this but on windows?
----- Original Message -----
From: "Myles" <my***@geocities.com>
Newsgroups: comp.lang.python
To: <py*********@python.org>
Sent: Wednesday, May 26, 2004 9:49 AM
Subject: Re: how to terminate a process on win32?

"Joe Wong" <jo*****@mango.cc> wrote in message news:<mailman.164.1085188722.6949.py*********@pyth on.org>...
os.popen2() to start my daemon, I can't figure out a way to stop it
'nicely'... Is there anything that I can do?


Mark Hammond's Python for Windows extensions includes a demonstration
of killing processes on Windows:

On my PC:
C:\Python23\Lib\site-packages\win32\scripts\killProcName.py

Python for Windows extensions:
http://starship.python.net/crew/mhammond/
https://sourceforge.net/projects/pywin32/

Regards, Myles.
--
http://mail.python.org/mailman/listinfo/python-list

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: deko | last post by:
I use the default windows phone dialer to make calls from an Access form. I close the phone dialer after the call is made using the below function. The problem is I'm not closing the Phone Dialer...
7
by: Andrew S. Giles | last post by:
Hello, I am looking for an article, or some information about how to get a C# windows forms application to trap the "End Process" event from the Task Manager? Is such a thing possible, and if...
3
by: Keith Grefski | last post by:
I cant seem to figure out how to terminate a process in vb.net i can do it using vbscript and wmi but terminate doesnt seem to exist in the available classes for wmi under vb.net
3
by: Peter Neuburger via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Peter Neuburger Hi Everybody, I need some help with the WMI Terminate Method. I have a Listbox where I get all the Process...
1
by: kk5151 | last post by:
Hi, Do you know any simple script to terminate the iexplorer.exe. On window, I have to go to Task Manager -> processes -> End process of "IExplorer.exe". Currently I have 30 IE browsers running on...
2
by: cnsabar | last post by:
Hi., I am using the following code to terminate the any process by giving the process name as input... use Win32::Process::List; use Win32::OLE; $Win32::OLE::Warn = 3; $P =...
0
by: cnsabar | last post by:
Hi., I need a Perl script to terminate the any running process in server. by specifying computer name and process name.. I have the following code to terminate the any process by specifying...
1
by: thunder54007 | last post by:
hi, here is my script: import win32con import time import wmi c = wmi.WMI() for process in c.Win32_Process(name = "notepad.exe"): print process.ProcessId, process.Name process.Terminate ()
2
by: Smokey Grindel | last post by:
Is there anyway to check if an external process is running, then terminate it if it is? my problem right now is in my installer the user might try to upgrade while the program is running... I want...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.