[Python-Dev] os.kill() on Win32 ? (Fork on Win32)
M.-A. Lemburg
mal@lemburg.com
Mon, 31 Jul 2000 12:21:09 +0200
Mark Hammond wrote:
>
> > Next, I'll have to find out how to kill a process given
> > its process ID under Windows... wouldn't it be possible to
>
> hprocess = OpenProcess( accessFlags, bInherit, pid );
> TerminateProcess(hprocess, exitCode);
Would it make sense to add something like this to posixmodule.c
as emulation of the Unix kill() on Win32 ?
Here's the manpage for reference:
SYNOPSIS
#include <sys/types.h>
#include <signal.h>
int kill(pid_t pid, int sig);
DESCRIPTION
The kill system call can be used to send any signal to any
process group or process.
If pid is positive, then signal sig is sent to pid.
If pid equals 0, then sig is sent to every process in the
process group of the current process.
If pid equals -1, then sig is sent to every process except
for the first one, from higher numbers in the process
table to lower.
If pid is less than -1, then sig is sent to every process
in the process group -pid.
If sig is 0, then no signal is sent, but error checking is
still performed.
RETURN VALUE
On success, zero is returned. On error, -1 is returned,
and errno is set appropriately.
> The hard bit on Win32 is finding the PID when you only have the process
> name (for example) but it sounds like you dont have that specific
> problem...
Not really, since my server manages its own set of processes
and knows the different PIDs. It keeps track of what the processes
currently do and terminates the ones that act in unexpected ways,
e.g. due to programming errors.
On Unix this results in a high availability bug tolerant
server application which allows running user written code. My future
goal would be porting it to Win2k, provided the needed APIs are
available (or can be emulated in some way).
--
Marc-Andre Lemburg
______________________________________________________________________
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/