1. Function Description:
Kill and raise are used to send signals:
Kill sends a signal to a process or process group, not only to abort the process, but to send other signals to the process;
The raise sends the signal to the (process) itself.
Their prototypes are as follows:
#include <signal.h>
#include <sys/types.h>
int Kill (pid_t pid,/* Indicates the signal process number to send * *
int signo);/* Signal * *
int raise (int signo);/* Signal//
Success returns 0, error returns-1
As you can see from the prototype, the raise function can be implemented by kill.
Raise (Signo);
Equivalent to:
Kill (Getpid (), signo);
2. Parameter description
PID Parameters:
The PID parameter in the Kill function, which has the following 4 kinds of conditions:
PID > 0: This signal is sent to the process with the process ID PID.
PID = 0: Sends the signal to all processes (excluding kernel processes and init processes) that belong to the same process group as the sending process. At this point, the sending process must have the right to send signals to these processes.
PID < 0: Send this signal to all processes whose process group ID equals PID absolute value (excluding kernel processes and init processes). At this point, the sending process must have the right to send signals to these processes.
PID = = 1: Sends the signal to all processes on the system where the sending process has permission to send signals to them. (excluding kernel processes and init processes).
Signo Parameters:
POSIX.1 defines a signal that is numbered 0 as an empty signal. If the Signo parameter is 0, the kill still performs a normal error check but does not send a signal. This is used to determine whether a process exists.