Signal processing function Set one:
#include <signal.h>
typedef void (*sighandler_t) (int);
sighandler_t signal (int signum, sighandler_t handler);
Signal (SIGNUM,FUNC); return Sig_err On Error
Send signal:
The KILL function sends a signal to a process or process group, and the raise function transmits the signal to itself
#include <sys/types.h>
#include <signal.h>
int Kill (pid_t pid, int sig);
- Pid>0 send signal to PID
- Pid=0 all processes that send signals to the process group to which the sending process belongs
- Pid=-1 sends a signal to all processes (of course, must have permission to send)
- Pid<-1 a process that sends a signal to all processes that the sending process belongs to the process group Id=-pid
#include <signal.h>
int raise (int sig);
setting alarms and suspending processes
#include <unistd.h>
unsigned int alarm (unsigned int seconds); After seconds seconds, a SIGALRM signal is generated.
int pause (void); Suspends the calling process until a signal is captured. After snapping to a signal and processing, pause will return, return value: -1,errno=eintr
Signal Processing Chapter