a urgent help needed in C

Banned
18Mar2010,01:48   #1
vignesh1988i's Avatar
How can END a process through a C program...... is there any function in C???????


it's urgent


thank s in advance
Go4Expert Member
18Mar2010,10:09   #2
karthigayan's Avatar
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).
Banned
18Mar2010,10:38   #3
vignesh1988i's Avatar
i think that is under LINUX.... i need in windows environment....... those functions (kill() & raise() ) will it work in DEV C++ compiler?????????
Light Poster
18Mar2010,11:46   #4
itstimetojazz's Avatar
Hi

Try using
Exit(0);

This will terminate ur calling process
Go4Expert Member
18Mar2010,14:00   #5
murugaperumal's Avatar
use the following function
Code:
exit(0)
Mentor
18Mar2010,14:01   #6
xpi0t0s's Avatar
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.
Banned
18Mar2010,17:43   #7
vignesh1988i's Avatar
hmmm .. you are right.. ok.. can u help me out for my problem....


thank u
Mentor
18Mar2010,20:00   #8
xpi0t0s's Avatar
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
Banned
18Mar2010,22:07   #9
vignesh1988i's Avatar
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........
Pro contributor
18Mar2010,22:12   #10
virxen's Avatar
try here
http://www.codeproject.com/KB/threads/killprocess.aspx