We always want to classify unknown events. When it happens, passing a piece of code as a parameter to other methods is the easiest way to do it, which means we want to work with the code like we do with the data.
A new process object can be created by proc:
ruby> Quux = proc {
| print "Quuxquuxquux!!! \ n "
| }
#
Now Quux points to an object, and like any other object, it has behavior that can be invoked. In particular, we can execute it using the call method:
Ruby> Quux.call
Quuxquuxquux!!!
, such as being removed by 0, and signals caused by events outside the process are called asynchronous signals, such as keystrokes. The user, kernel and process can generate send signal: (1) The user presses the interrupt combination key "Ctrl" + "C", the terminal driver receives the input character, and calls the signal system, the signaling system sends the SIGINT signal to the Shell,shell to send it to the process, Process received
process: $ Ps-axu | grep MONGO Confirmation log: Cd/data/logtail-f Mongodb.logSecure Stop MongoDB processSend a signal to the MONGODB process to stop MongoDB, if you want to safely stop can have two signals: SIGINT signal, or how to stop the sigterm signal: $ kill-2 8888 Where 8888 is the Mongod process number, which can be obtained through Ps-axu |grep MONGO, 2 means sending a mongod signal to the SIGINT
complete.Confirmation Process:$ Ps-axu | grep MONGOConfirmation log:Cd/data/logTail-f Mongodb.logSecure Stop MongoDB ProcessSend a signal to the MONGODB process to stop MongoDB, if you want to safely stop can have two kinds of signals: SIGINT signal, or sigterm signalHow to stop:$ kill-2 8888Where 8888 is the Mongod process number, which can be obtained through Ps-axu |grep MONGO;-2 means sending SIGINT
My knowledge is not deep, the following content is on-line harvesting for future use.
Signal
Signal Detail Description
Concise Description
processing Mode
1) SIGHUP
This signal is issued at the end of the user terminal connection (normal or abnormal), usually at the end of the control process of the terminal to notify the same session of the various jobs, when they are no longer associated with the control terminal.
Connection Hang-off
, about the signalHistorically, 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.Both kill and trap can see the signal number and its associated name. "Signal" refers to events that are sent asynchronously to a program. By default, they usually terminate the operation of a program.# trap-l1)
process does not have a child process then return-1, and set errno if(errno! = echild) {Perror ("Sig_int Error");Exit(-1); }Exit(0);}Follow here:for0;i for( ; ; ) //parent just pause pause(); //everything done by childrenThe nchildren here are extracted from our parameters, representing the number of pre-derived child processes. For PIDs arrays, the Child_make () function is used to derive the child process, while the PID of the child process is returned to an item in the PIDs arr
Linux Process signal SIGHUP terminate process terminal line hang up SIGINT terminate process interrupt process Sigquit build core file terminate process and generate core file Sigill build core file non- Sigtrap Set up core file tracking self-trapping Sigbus establish core file bus error SIGSEGV establish core file segment illegal error SIGFPE build core file floating point exception Sigi OT build core File Execution I/o self-trapping sigkill terminat
program*/voidHandler_sigint (intSigno, siginfo_t *siginfo,void*pvoid) {printf ("recv SIGINT, the data value is:%d\n", siginfo->si_int);}intMain () {structSigaction Act; /*Assignment Act Structure*/act.sa_sigaction=Handler_sigint; Act.sa_flags= Sa_siginfo;//Specify a signal processing function that uses three parameters /*installing signal processing functions*/sigaction (SIGINT,Act, NULL); while(1)
seconds left in the previously scheduled timeout. A process can only set a time-out to set seconds to 0 to cancel the previous timeout setting. //Capturing signals#include #include#includestring.h>#include#include#includevoidCatch_signal (intSign ) { Switch(sign) { CaseSIGINT://SIGINT default behavior is to exit the processprintf"SIGINT signal\n"); Exit (0); Break; CaseSIGALRM://SIGALRM default behavi
state of the last command executed, unless a syntax error occurs, which returns a value other than 0.19. SignalIf bash is interactive and does not have any traps, it ignores sigterm (so that kill 0 does not end the interactive shell), SIGINT is captured and processed (so that the built-in command wait can be interrupted). In all cases, Bash ignores sigquit. If job control is functioning, Bash ignores sigttin, Sigttou, and SIGTSTP.Non-built-in command
() is being called, and the SIGINT and sigquit signals are ignored. return value =-1: Error = 0: The call succeeded but no child process >0: The ID of the child process that successfully exited if system () fails on call to/bin/sh returns 127, other failure causes return-1. If the argument string is a null pointer (NULL), a non-0 value of > is returned. If the system () call succeeds, the return value after executing the shell command is returned, bu
Transferred from: http://blog.csdn.net/yusiguyuan/article/details/43272225After finishing:Signal SignalIn UNIX systems, software interrupts are implemented with signalsSignal to parent process, end of child processAn interrupt is a program that terminates execution of the current code and executes other code insteadInterrupts are broken down into software interrupts and hardware interrupts, hardware interrupts are software interrupts, and hardware interrupts are hardware failures that result in
=3.0.5]Start service: rsync--daemon--config=/etc/rsyncd.conf4. Full disk spaceRsync:recv_generator:mkdir "/teacherclubbackup/rsync ..." failed:no spaces left on device (28)Skipping any contents from this failed directory * * *5, CTRL + C or a large number of documentsRsync error:received SIGINT, Sigterm, or Sighup (code) at RSYNC.C (544) [receiver=3.0.5]Rsync error:received SIGINT, Sigterm, or Sighup (code)
-zero, then a signal code
4. exit
Exits the process. Process Communication , signaling
Most of the signal types that Linux provides are for the kernel to use, and only a handful of signals can be used to transfer between processes. Here are the common signals and their meanings:
sighup
When terminating a terminal, the kernel sends this signal to all processes controlled by the terminal. Usually the case
, the control terminal of a process group is the terminal that the user own
, so that the signal is not nested in response during execution.Why do you block a signal? Let's take a look at the treatment of Ctrl_c. As you know, when a program is running, click Ctrl_c on the keyboard, the kernel will send a SIGINT signal to the corresponding process, and the default action for this signal is to end the process by Do_exit (). However, some applications may have their own processing for Ctrl_c, so set up a handler for
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.