Signal Processing Chapter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.