a urgent help needed in C

vignesh1988i's Avatar
Banned
How can END a process through a C program...... is there any function in C???????


it's urgent


thank s in advance
0
karthigayan's Avatar, Join Date: Feb 2010
Go4Expert Member
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).
0
vignesh1988i's Avatar
Banned
i think that is under LINUX.... i need in windows environment....... those functions (kill() & raise() ) will it work in DEV C++ compiler?????????
0
itstimetojazz's Avatar, Join Date: Sep 2009
Light Poster
Hi

Try using
Exit(0);

This will terminate ur calling process
0
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
use the following function
Code:
exit(0)
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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.
0
vignesh1988i's Avatar
Banned
hmmm .. you are right.. ok.. can u help me out for my problem....


thank u
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
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
0
vignesh1988i's Avatar
Banned
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........
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
try here
http://www.codeproject.com/KB/threads/killprocess.aspx