Old boy Education daily-69th Day-shell scripting Knowledge Points: What are trap signals in Linux system scripts and how do I use them?

Source: Internet
Author: User

Topic

Shell Scripting Knowledge points: What are trap signals in Linux system scripts and how are they used?

Reference answer: "Trap signal Command description"

The trap command is used to specify the actions to be taken after a signal is received, and a common use of the trap command is to complete the cleanup work when the script is interrupted.
Historically, the shell always used numbers to represent the signal, and the new script should use the name of the signal, which was saved in the Signal.h header file included with the # include command, and the sig prefix needed to be omitted when using the signal name.
You can enter the command trap-l at the command prompt to view the signal number and its associated name.

"Trap Signal Command Usage"

The parameters of the trap command are divided into two parts, the first part is the action to be taken when the specified signal is received, and the latter part is the signal name to be processed.
· To reset the processing condition of a signal to its default value, simply set the command to-.
· to ignore a signal, set command to an empty string '
A trap command without parameters will list the current set of signals and their actions.

"Trap Important signal description"
Signal Information Signal Description
HUP (1) Hangs, usually caused by a terminal drop or user exit
INT (2) Interrupt, usually caused by pressing CTRL + C key combination
QUIT (3) Exit, usually caused by pressing the ctrl+\ key combination
ABRT (6) Abort, usually caused by some serious execution error
ALRM (14) Alarms, typically used to process timeouts
Term (15) Terminated, usually sent at system shutdown
Note

Today is the day to accompany everyone's first __69 days __, look forward to your progress.
For questions and answers, please leave a comment in the blog comments section.
Index of the topic of the previous period
http://lidao.blog.51cto.com/3388056/1914205

This article is from the "Lee blog" blog, make sure to keep this source http://lidao.blog.51cto.com/3388056/1936555

Old boy Education daily-69th Day-shell scripting Knowledge Points: What are trap signals in Linux system scripts and how do I use them?

Related Article

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.