Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   a urgent help needed in C (http://www.go4expert.com/forums/urgent-help-c-t21400/)

vignesh1988i 18Mar2010 01:48

a urgent help needed in C
 
How can END a process through a C program...... is there any function in C???????


it's urgent :)


thank s in advance

karthigayan 18Mar2010 10:09

Re: a urgent help needed in C
 
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).

vignesh1988i 18Mar2010 10:38

Re: a urgent help needed in C
 
i think that is under LINUX.... i need in windows environment....... those functions (kill() & raise() ) will it work in DEV C++ compiler????????? :):nice:

itstimetojazz 18Mar2010 11:46

Re: a urgent help needed in C
 
Hi

Try using
Exit(0);

This will terminate ur calling process

murugaperumal 18Mar2010 14:00

Re: a urgent help needed in C
 
use the following function
Code:

exit(0)

xpi0t0s 18Mar2010 14:01

Re: a urgent help needed in C
 
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.

vignesh1988i 18Mar2010 17:43

Re: a urgent help needed in C
 
hmmm .. you are right.. :) ok.. can u help me out for my problem.... :)


thank u

xpi0t0s 18Mar2010 20:00

Re: a urgent help needed in C
 
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

vignesh1988i 18Mar2010 22:07

Re: a urgent help needed in C
 
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........ :)

virxen 18Mar2010 22:12

Re: a urgent help needed in C
 
try here
http://www.codeproject.com/KB/threads/killprocess.aspx


All times are GMT +5.5. The time now is 21:50.