Killing process generated by separate thread
Posted by Dimon (Dimon), 21 July 2005While writing a shell for my console c++ program, find a problem with killing process. Tcl script opens new thread which generates new process for reading data from my C program:
SendCmd script is:
directive - command line
cat - program for catching errors
ConsoleArea - Text widget for showing text information returned by C++ program
WriteLog is a script for logging and shutting down thread:
When I call process::release $listener later, I successfully kill the thread but program that was run in that thread still work.
According to TCL manual, in UNIX to killing a process possible with kill command.
How can I do it in Windows 2000 ?
OS: Windows 2000 Pro SP4
Tcl version: 8.4.2 with thread support
Tk version 8.4.2 with thread support
Both compiled by my own.
Posted by admin (Graham Ellis), 27 July 2005I'm not familiar with killing processes under Windows ... I specialise in the Open Source programming languages themselves, with some Unix and Linux thrown in. I was hoping that someone else might chime in with and answer here but ... sorry ... I don't think any of the other regulars know either.
Anyway - this follow up post at least assures you that we've looked at the question and will also bump it to the top of the pile to highlight it again.
Posted by neo (The Architect), 28 July 2005You would have to use some third party tool for this I think.
I googled for it and this looks like a possible tool for it http://www.xmlsp.com/pview/prcview.htm
Posted by neo (The Architect), 28 July 2005Ok I found it. You do not need to have a third party tool.
Windows XP has a command "tskill" for this. I think on some other versions of Windows its called "taskill".
Just check and let us know.
Posted by Dimon (Dimon), 9 August 2005All hail, gentlemen!
Thank you ever so much for your attention for my question. I try to search any command like "taskill" in Windows 2000 Pro but don't found it yet. But I tried an alternative way to solve my problem and wrote small program witn C language that using TerminateProcess() WIN API function to kill a process. But I found a second problem with determine a process handle in TCL.
The pid function returns me a process handle in uncustomary format for me: it seems like "123 4567".
How can I aright encode this format to accustomed hex view to send this handle correctly in TerminateProcess() WIN API function?
Posted by Dimon (Dimon), 6 October 2005Well, I return to this task and solve the problem.
In this code snippet:
pids - the process Id seems like "123 4567".
So I take a series of experiments and looked accurately at the information about PIDs in Windows 2000 Task Manager. I have found that 1-st part of $pids is a true process identifier!
But I don't know about purpose of second part yet.
To kill a process spawned in separate thread I done the next.
I call thread::release function to release the thread.
After that I can to kill the process spawned in thread.
I call a small C++ program that kills a process and send as a parameter 1-st part of "pids" variable's value:
I think the next step would be a wrapping this C++ function as Tcl-extention.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho