Signal communication programming, Wang Ming Learning Learn

Source: Internet
Author: User

Signal Communication Programming

In the Linux system, the signal (signal) is also the oldest inter-process communication mechanism.

First, the signal type

All the signals supported by the Linux system are defined in/usr/include/asm/signal.h (display), where the common signals are:

SIGKILL: Kill Process

SIGSTOP: Pausing a process

SIGCHLD: Used to notify the parent process when a child process stops or ends

Second, function learning

2.1 Sending a signal

Name of 2.1.1 function

Kill

2.1.2 Function prototype

int Kill (pid_t pid,int SIG);

2.1.3 Function function

Send a signal to a process

2.1.4 Owning header file

<sys/types.h> <singl.h>

2.1.5 return value

Success: return 0

Failure: Return-1

2.1.6 parameter Description

Pid:if (pid>0), the PID parameter points to the process of receiving the signal

SIG: Used to indicate the signal we're sending.

2.2 Processing Signal

Name of 2.2.1 function

Signal

2.2.2 Function prototype

typedef void (*sighandler_t) (int);

sighandler_t signal (int signum,sighandler_t handler);

2.2.3 function function

Set the signal processing mode

2.2.4 Owning header file

<signal.h>

2.2.5 return value

Success: Returns a pointer to the handler function

Failed: Return Sig_err

2.2.6 parameter Description

Signum: The signal to be processed

Handler: The corresponding signal processing method, can be value (3 kinds)

Sig_ign: Ignoring this signal does not handle

SIG_DFL: Handing over to kernel processing

User-defined functions: User-defined function handling

Signal communication programming, Wang Ming Learning Learn

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.