Linux signal Processing--several system calls related to information

Source: Internet
Author: User

First, sigaction function

#include <signal.h>

int sigaction (int sig,const struct sigaction* act,strcut sigaction* oact);

The sig parameter indicates the type of signal to be captured, the act parameter specifies a new signal processing mode, and the Oact parameter outputs the previous processing of the signal (if not null), and both act and oact are pointers to the sigaction struct type

Signal Set function

#include <signal.h>

int Sigemptyset (sigset_t* _set)

int Sigfillset (sigset_t* _set)

int Sigaddset (sigset_t* _set,int signo)

int Sigdelset (sigset_t* _set,int signo)

int Sigismember (const siggset_t* set,int signo)

Process Signal Mask

Specifies the signal mask of the process so that such a signal cannot be sent to the process

int sigprocmask (int _how,const sigset_t* set,sigset_t* oset);

How parameters are of type

Sig_bloc The new process mask is the set of its current value and _set specified signal set

Sog_unblock the new process signal mask is the intersection of its current value and the ~_set signal set, so _set the specified signal set will not be masked

Sig_setmask set the process mask directly to _set

Signals that are hung up

After the process signal mask is set, the masked signal will not be accepted by the process, and if a blocked signal is sent to the process, then the operating system sets the signal to a suspended signal of the process, and if we suppress the signal, it can be immediately received by the process, the following function can get the signal set that the process is currently suspended

int sigpending (sigset_t* set);

Even if a process receives the same suspended signal multiple times, the sigpending function can only be reflected once, and when we use Sigprocmask again to enable the pending signal, the signal's handler function is only triggered once.



Several special signals related to network programming:

SIGHUP:

When the control terminal of the process is suspended, the sighup signal is triggered, and for a network daemon without a control terminal, they usually use the sighup signal to force the server to reread the configuration file

Sigpipe

By default, writing data to a pipe or socket that is closed to a read end will cause the sigpipe signal to be raised, sigpipe the default relief is to end the process and need to modify such default behavior.

We can also use the I/O multiplexing system to detect if the read end of the pipe and socket connections has been closed. As an example of poll, when the read end of a pipe is closed, the Pollhup event on the write-side file descriptor is triggered, and the Pollrdhup event on the socket is triggered when the socket connection is closed by the other side.

Linux signal Processing--several system calls related to information

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.