Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
how to terminate a process on win32?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joe Wong  
View profile  
 More options May 21 2004, 9:18 pm
Newsgroups: comp.lang.python
From: "Joe Wong" <joew...@mango.cc>
Date: Sat, 22 May 2004 09:18:33 +0800
Local: Fri, May 21 2004 9:18 pm
Subject: 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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fraser  
View profile  
 More options May 24 2004, 10:38 am
Newsgroups: comp.lang.python
From: David Fraser <dav...@sjsoft.com>
Date: Mon, 24 May 2004 16:38:02 +0200
Local: Mon, May 24 2004 10:38 am
Subject: Re: how to terminate a process on win32?

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hung Jung Lu  
View profile  
 More options May 24 2004, 6:11 pm
Newsgroups: comp.lang.python
From: hungjun...@yahoo.com (Hung Jung Lu)
Date: 24 May 2004 15:11:49 -0700
Local: Mon, May 24 2004 6:11 pm
Subject: Re: how to terminate a process on win32?

"Joe Wong" <joew...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Stockwell  
View profile  
 More options May 25 2004, 7:03 am
Newsgroups: comp.lang.python
From: "David Stockwell" <winexp...@hotmail.com>
Date: Tue, 25 May 2004 11:03:37 +0000
Local: Tues, May 25 2004 7:03 am
Subject: Re: how to terminate a process on win32?
Just my 2cents....

There is an undocumented feature..
UINT uExitCode  <--

I don't remember all the details, but I've used it in the past.

if you set the exit code to a certain number (i don't recall what but it is
possibly -1, 0, or 1... maybe 2 or -2) then the OS will force a 'shut'
beyond the normal call to terminate process.

When the OS is 'shutting down' it calls TerminateProcess on each process
passing that value.   This trick prevents processes from restarting (if you
have a process like explorer that you are trying to kill).

Since I don't recall the details, it would take a bit of experimentation.  
But hopefully not too much.

David
=====================
http://cellphone.duneram.com
"Surf a wave to the future"
I'm a windows SDK CBT guru with a patent....

_________________________________________________________________
Express yourself with the new version of MSN Messenger! Download today -
it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Myles  
View profile  
 More options May 25 2004, 9:49 pm
Newsgroups: comp.lang.python
From: my...@geocities.com (Myles)
Date: 25 May 2004 18:49:09 -0700
Local: Tues, May 25 2004 9:49 pm
Subject: Re: how to terminate a process on win32?

"Joe Wong" <joew...@mango.cc> wrote in message <news:mailman.164.1085188722.6949.python-list@python.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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe Wong  
View profile  
 More options May 26 2004, 10:32 pm
Newsgroups: comp.lang.python
From: "Joe Wong" <joew...@mango.cc>
Date: Thu, 27 May 2004 10:32:54 +0800
Local: Wed, May 26 2004 10:32 pm
Subject: Re: how to terminate a process on win32?
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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Peters  
View profile  
 More options May 26 2004, 10:58 pm
Newsgroups: comp.lang.python
From: "Tim Peters" <tim....@comcast.net>
Date: Wed, 26 May 2004 22:58:12 -0400
Local: Wed, May 26 2004 10:58 pm
Subject: RE: how to terminate a process on win32?
[Joe Wong]

> 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?

There is no way guaranteed to work on Windows.  This MS article explains the
*intended* way, but many apps (and especially console apps) don't play this
game:

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q178893

The short course is that native Win32 programs with a GUI "should" be
running a message pump, and their top-level window should respond to a
WM_CLOSE message by shutting down the app cleanly.  If they're not coded
that way, then no, you have in general no way to force them to shut down
cleanly.  Googling will turn up many approximations that more-or-less work
for different kinds of apps.  Bottom line is really that life is sheer hell
unless the process you're trying to shut down *advertises* a way to force
that from outside (like responding to WM_CLOSE, or the state of a global
semaphore, or a particular string of bytes sent to an agreed-upon socket,
etc).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »