How can END a process through a C program...... is there any function in C??????? it's urgent thank s in advance
Using the function kill() you can end the process ,for this you need the process id .The function raise() will end the current process . Code: man 2 kill man raise In the kill function you can send a signal as a second argument to end the process.There are various signals to do this like (SIGKILL,SIGSROT,SIGTERM,etc).
i think that is under LINUX.... i need in windows environment....... those functions (kill() & raise() ) will it work in DEV C++ compiler????????? :nice:
Help with you is always urgent. Why not try asking sooner? Don't leave it so long before tackling the task then you won't be as stressed out.
It's not easy: you have to find the process's main window and post it a WM_CLOSE message. There are WinAPI functions to help you with this though; see EnumWindows. See also http://support.microsoft.com/kb/178893
oh... is it !!!! fine.... ..... wat about kill() function , whether we can we use that ........... I am having DEV C++ compiler.... whether kill() will work in my compiler??? i saw that function in sys.h file.. i hope u know this int kill(pid_t pid, int sig); here 'sig' refers to the signal ... in Linux it's easy to get the signal no. which is equivalent to termination of that process corresponding to the given PID no. ... but how to find the same signal number for WINDOWS.... or we have same signal formats for all OS??? plz. help me out........
Well you can try it. Get the PID from Task Manager, and the terminate signal is 9, so if the PID is 1000 the call would be kill(1000,9); If that terminates the process then it works; if not then it doesn't. The only way I can tell you if it works is to get DevC++ myself, install and test it, and since you already have it installed it's easier for you to do it.
hmmmm... i too tried that alsoo.. i included all header files like : sys/types.h , signal.h , even process.h..... it's showing the error as kill() not found... first added a header file as i have referred , all are saying kill() function is present in above mentioned one of these header file .... so still am searching where this kill() function is stored in DEV C++...... so can u help me still thank u S.R.Vignesh
Probably it's a linker error then if you've found it in an include file and included that file. So you need to find out which library it's in and link that with the program. On the other hand if it's a compiler error then you don't actually need to #include anything; just copy the prototype into your program. The usual way to find out which library a function is included in is to check the documentation for that function and it will tell you. Or it could be described in the header file. If not then you'll need to hope that someone else round here knows DevC++ or ask at the DevC++ forum on SourceForge.
kill is unix based,there is no way it will work in windows, stop trying. the link i send ,tells you the way it can be done in windows,so read it. http://www.codeproject.com/KB/threads/killprocess.aspx also check the links inside the above link.
Every process in Windows has a process ID; open Task Manager, switch to the Processes view and make sure the PID column is enabled. There's a kill program on MSDN. What I don't know is what it does internally; maybe it calls a system kill() library, or maybe it enumerates windows and finds process ID's (instances) from the main window. http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx