Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

kill - Send signal to own program

&pagelevel(4)&pagelevel

Definition

#include <signal.h>

int kill(int pn, int sig);

kill continues to be supported for compatibility reasons; it works like the ANSI function
raise.

The only difference is that the kill function expects the program number pn as the first
argument, which must always be 0 since the signal may only be sent to its own program
(see also return value -1).

Return val.

0

-1

The signal was sent successfully.

The signal could not be sent, because

  • sig is not a valid signal number or

  • the program number pn is not equal to 0.

In addition, errno is set to the appropriate program error code:
EINVAL (invalid signal number)
ESRCH (program number not 0).

Example

A program that aborts itself.

#include <signal.h>
int main(void)
{
  for(;;)
    kill(0, SIGKILL);
  return 0;
}

See also

alarm, raise, signal