kill(0,-9) don't kill the process

Hi all
i have simple c program , when i wish to kill the app
im using kill(0,-9) , but it seams this command don't do any thing and the program.
just ignore it .
what im doing wrong here ?
im using HP-UX ia64

Thanks

You can kill a program with command:
kill -9 <PID of programme>
If you can not necessary permission about programme, You won't kill a programme.

Best regards,
Iliyan Varshilov

i need to kill from c program

If you need killing a process from C programme, You will read about system call 'kill'.

http://www.freebsd.org/cgi/man.cgi?query=kill&apropos=0&sektion=2&manpath=FreeBSD\+6.2-RELEASE&format=html

Best regards,
Iliyan Varshilov

hi
i have read it also read this :
http://www.cs.cf.ac.uk/Dave/C/node24.html#SECTION002410000000000000000
that helped me understand this is my code:

int k=kill(getpid(),-9);
int r=raise(-9);

the return codes from k and r is -1
that is it proform the kill command but failled , the question is why ?
the getpid() also returns the right pid .
so what can i do next ?
how can i catch errno msg?
what else i can do to understand what is wrong ?

thanks

You can get a error in string format from your programme with function 'strerror'.
This is part of code you needed:

#include <errno.h>
#include <stdio.h>

fprintf(stderr, "Error: %s\n", strerror(errno));

This man page describes 'errno'.
http://www.freebsd.org/cgi/man.cgi?query=errno&apropos=0&sektion=0&manpath=FreeBSD\+6.2-RELEASE&format=html

This man page describes 'strerror'.
http://www.freebsd.org/cgi/man.cgi?query=strerror&apropos=0&sektion=0&manpath=FreeBSD\+6.2-RELEASE&format=html

Best regards,
Iliyan Varshilov

You can some mistakes in your code:

The first mistakes in line - 'kill(getpid(),-9);'
In the Unix basic systems have not a signal with id '-9', but have a signal with id '9'.
Try with int k=kill(getpid(),SIGKILL);

The second mistakes is similar that first - 'int r=raise(-9);' .

The third mistakes:
You don't kill process whit 'raise', because process one killed from 'k=kill(getpid(),SIGKILL);'

Do you really need killing a current process ?

Best regards,
Iliyan Varshilov

hi and thanks for the reply after fixing this its working great
but one thing .. im getting
"Killed" stdout after kill is done , how can i remove this print?

That was printed by the shell who was the actual parent of the process.

I recommend not using SIGKILL, it's very crude and impolite. You should really be sending a SIGINT, SIGTERM or SIGQUIT which tells the process to clean up nicely. If a process has opened resources that are not automatically cleared up then SIGKILL will leave those resources hanging around.

You should read more about IPC (interprocess communications ) in Unix basic system.

This is a good book about IPC.
http://www.amazon.com/UNIX-Network-Programming-Interprocess-Communications/dp/product-description/0130810819

Best regards,
Iliyan Varshilov