Version 12 of kill

Updated 2004-11-04 12:43:13

TclX provides a kill command only for Unix(-like) systems.


"kill" is rather foreign to Windows programming.

(LV I don't understand why this would be so - how is kill different than the control-alt-del End Task?)

From a programming standpoint, one generally sends a {WM_CLOSE,WM_QUIT,...} to a Win32 application (Tcl programmers can "send" such messages with winutil::sendmessage).

Windows workers also should be aware of

  • the sample /samples/sdktools/winnt/tlist/kill.c included with the Win32 SDK (still there in recent versions?)
  • the "WinTop" or "Windows Process Watcher" (it's had different names at different times) utility Microsoft makes available as part of its "Kernel Toys" [L1 ]

TV The idea is that one has processes, also on windows, which are assigned 'running time' by a 'scheduler/dispatcher/time slicer/...' process which is part of the kernel, lets say the thing that runs when windows runs, and that that thing has a list of processes it maintains as part of the pool of processes that might get some processor time at some point, and than by that thing get that, for instance in round-robin fashing when of equal priority. A process can be not taking part in the multitasking form of semi-parallel running processes while waiting for something, and the process can be terminated somehow, so that it is no longer part of the pool of processes the operating system considers active, and its memory and place in the running process list can be forgotten and reused.

Normally, one would want the termination of a process do go strickly under our control, neatly, and *when* we want to, for sure, which is all very debatable, and in practice at times problematic, especially under windows.

Under unix, you'd want the process to call a special OS function exit(), which never returns, under windows similar things can happen. The idea is that signals under unix, and a sort of comparable idea under windows can inform a program (running as one or more processes) that there is a request to terminate it, or that that will happen soon, so that it can clean up and save some stuff, and things can go gracefully.

Under unix, the command to send what are called signals, of which KILL is one, and often TERM(inate) another, is called kill:

   kill -KILL <process_id>

under unix, when the issuer of it has sufficient rights, for almost certain makes sure that some milli seconds later the process with that PID (process identifier number) is killed.

Under windows, I don't remember exactly for older versions, but under recent XP there is a similar command, albeit more simplistic, and as I remember only intended for what the name suggests (in unix, kill can also put a process to sleep or alert it and some more things) called tskill:

   tskill <windows_PID>

Under unix/linux, the command ps gives you the PID's, to get all processes visible to you given your rights is:

   ps -aef | more

Under windows, you'd have to check the task manager window. Unless you have cygwin installed, than cygwin-started processes have a ps compatible PID, and you can use the cygwin kill, or you can use:

   ps -W

to get a list of windows processes and their windows PID suitable for use with tskill.


SO Oct 13, 2001

 Well, everyone, there IS a Santa Claus.

 For windows98 (at least), tlist.exe and kill.exe are available from MS:
 (tlist gets you all the pids running)
   ftp://ftp.microsoft.com/services/technet/samples/ps/win98/reskit/diagnose/

 tlist and kill from the NT Resource kit *will not work* on win 98.
 (Yes, I *TRIED* them both, you never know for sure...)

 I hope that others may find this both helpful and useful.

 I *think* that the win95 resource kit is still downloadable
 somewhere on the MS site.

EF Nov 04, 2004

Sysinternals is making available a number of freeware [L2 ] for process listing, killing, etc. These are very capable utilities and I have been using them extensively. They are tuned for being called from the command line!


In a newsgroup posting [L3 ], Victor Wagner nicely illustrates the "graceful degradation" or "graduated capability" idiom with kill as an example.