how to terminate a process on win32?

David Stockwell winexpert at hotmail.com
Tue May 25 07:03:37 EDT 2004


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




>From: hungjunglu at yahoo.com (Hung Jung Lu)
>To: python-list at python.org
>Subject: Re: how to terminate a process on win32?
>Date: 24 May 2004 15:11:49 -0700
>
>"Joe Wong" <joewong at 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
>--
>http://mail.python.org/mailman/listinfo/python-list

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





More information about the Python-list mailing list