Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

killing your own process - C++, UNIX 1

Status
Not open for further replies.

arunsrini

Programmer
Nov 24, 2003
2
US
Hello,
Would I be able to kill my own process using C++ on UNIX? i.e something like

void func() {

pid_t pid = getpid();

kill (pid, -9);

}

I am trying to do that, but it doesnt work. So can a process be killed only by another process and not from within itself?

Thanks,
-Arun
 
What makes you think the value of SIGKILL is -9? You'd be better off just using SIGKILL.

Are you confusing negative nine for the dash nine you might use on the command line?


Also, if all you want is for your program to stop, why go to all the trouble? Just use exit().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top