LinuxC signal - one of inter-process communication

1 signal characteristics: 
  simple but unreliable and can not carry large amounts of information, specific conditions before the trigger.
  Including software and hardware interrupts.
    Software interrupts such as: call abort, raise, alarm, setitimer trigger functions such as interrupt
    hardware interrupt such as: Bus 0 caused SIGFPE (floating point exception), resulting in unauthorized access to the contents of SIGSEGV (segmentation fault), aligned as a result of illegal content in addition to error (SIGBUS), etc.

2. The signals of the three elements:
  1) No: No signal ranges from 1 to 64.1 to 31 is a conventional signal number. 34-64 for the real-time signal.
  2) Event: while each number corresponds to a trigger event. The 1-> SIGHUP, 2-> SIGINT, 3-> SIGQUIT, ... man 7 signal can view all signals.
       Common corresponding event: Ctr + c generates SIGINT (2), Ctrl + \ generating SIGQUIT (3), Ctrl + z produce SIGTSTP (20),
       division by zero generate SIGFPE (8) floating point exception, invalid memory access generated SIGSEGV (11) segmentation fault, illegal memory alignment and other produce SIGBUS (7) bus error
  3) default action: terminate the process, including Term, Ign flicker, Core Core terminate the process and generate documents, Stop pause process, Cont continues.
        Note: SIGKILL (9) and SIGSTOP (19) does not allow the signal is masked, ignored, capture, etc., can only execute the default action. SIGKILL default termination process, SIGSTOP default pause process.

3. The signal transmission function
  kill (pid, sig) function: transmitting a signal sig. pid> 0 to the specified process sends a signal sig, pid = 0 transmit signal sig to the same process group, pid <-1 transmit signal sig to a specified process group, pid = -1 signal sig is sent to all processes.
  raise (sig) function: sig signal is sent to the current process.
  abort () function: send SIGABRT signal to the current process.
  Alarm (sec) Function: Indicates the current process to transmit a signal after SIGALRM sec sec is greater than 0 seconds. sec = 0 expressed cancel the timer. Each process there is only one timer.
  setitimer () function: cycle timer, Which optional: ITIMER_REAL (NATURAL timing signal generating SIGALRM), ITIMER_VIRTUAL (virtual space user timing signal generating SIGVTALRM), ITIMER_PROF (running timing signal generating SIGPROF)
          
3. Set signal

  


 

Guess you like

Origin www.cnblogs.com/yongfengnice/p/11953839.html