We always want to classify unknown events. When it happens, pass a piece
Code Is the easiest solution, that is, we want to process code like processing data.
A new process object can be created through proc:
Ruby> quux = proc {| Print "quuxquuxquux !!! \ N"|}#
Now, quux points to an object. Like other objects, it can also be called. In particular, we can use the call method to execute it:
Ruby> quux. CallQuuxquuxquux !!!Nil
Can quux be used as a method parameter? Of course.
Ruby>
Traditionally, the system signal is the control signal transmitted by the system to the process. For example, SIGINT and sigterm. The transmission of these signals usually indicates the relevant process to complete the corresponding operation, or suspend or terminate, or some other operations. In tor systems, there are two types of signals: traditional signals and controller signals. BelowCodeSection is a simple list of these signals:
/* These signal
externally using the KILL command, typically a job control signal such as SIGINT, SIGHUP, then all threads are traversed until a thread that does not block the signal is found and then called to process. (typically found from the main thread), note that only one thread can receive it.
Second, each thread has its own separate signal mask, but all threads share the signal action of the process. This means that you can call Pthread_sigmask (not sig
;
//////////////////////////////////////// //////////////////////////////////////// ////////////
// Function: sig_brk (), signal handle, close deviceHandle then exit, if press CTL-C or CTL -\
// Param: signo, the signal number
// Return: void
//////////////////////////////////////// //////////////////////////////////////// ////////////
Static void
Sig_brk (int signo)
{
If (sig
. The result is as follows:
[purple@localhost review]$ gcc test.c[purple@localhost review]$ ./a.out^Csig_num: 2select: Interrupted system callhello world!hello world!
Because SIGINT has been registered through signal (2, handler);, it is clear that after pressing ctrl + c, the signal processing function handler will naturally capture this signal, therefore, ^ Csig_num: 2 is displayed.
The select function processes the interrupt signal. When an interru
signal is used to notify it to reread the configuration file.2) SIGINTA program termination (interrupt) signal, issued when the user types the intr character (usually ctrl-c), to inform the foreground process group that the process is terminated.3) SigquitSimilar to SIGINT, but controlled by the quit character (usually ctrl). The process generates a core file when it receives a sigquit exit, similar to a program error signal in this sense.4) SigillAn
signal is used to notify it to reread the configuration file.2) SIGINTA program termination (interrupt) signal, issued when the user types the intr character (usually ctrl-c), to inform the foreground process group that the process is terminated.3) SigquitSimilar to SIGINT, but controlled by the quit character (usually ctrl). The process generates a core file when it receives a sigquit exit, similar to a program error signal in this sense.4) SigillAn
#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 behavior is to exit the processprintf"SIGALRM signal\n"); Break; Casesigkill:printf ("SIGKILL signal\n"); Break; }}//It is recommended to use the mysignal after encaps
void func (int), or the following special value:
sig_ign : Ignore signal
SIG_DFL : Default behavior for recovering signals
Say so much, or give an example to illustrate, the source file is named signal1.c, the code is as follows:#include The results of the operation are as follows:As you can see, the first time you press the abort command (CTRL + C), the process is not terminated, and the polygon is the output ouch! -I got signal 2, because the default behavior of
Blog gradually migrated to, independent blog, the original address http://www.woniubi.cn/two_groups_signal_difference/Before looking at the signal, there is not much attention to the comparison of different signals. When I see it again today, I suddenly feel very similar to some of the signals, and even very easy to confuse. Let's take a moment to summarize this weekend.First set of shutdown process signalsThe common 4 off process signal is sigkill,sigint
sentence defines a function pointer type called Sig_handler, which takes an int parameter with no return value.The second sentence declares the signal function, accepts a signum and a sig_handler, and returns the old Sig_handler.4. Possible types of SIG signals1) #define SIGHUP 1/* hangup */Sighup is a common signal used by UNIX system administrators. Many background service processes will re-read their configuration files after receiving the signal. However, the actual function of the signal i
threads. The method is often used only in a short time, and then released. In addition to your own thread, the Boost.asio itself contains several threads. However, you can ensure that those threads do not call your code. This also means that only the thread that called the Io_service::run () method calls the callback function. more than just network communicationIn addition to network communication, Boost.asio also contains other I/O functions. Boost.asio supports semaphores such as sigterm (so
command have been Completed. During execution of the command, SIGCHLD would be blocked, and SIGINT and Sigquit would be ignored. The system () function calls/bin/sh to execute the command specified by the parameter,/bin/sh is typically a soft connection, pointing to a specific shell, such as the BASH,-C option, which tells the Shell to read the command from the String command, and during the command execution, SIGCHLD is blocked, like saying: Hi, ker
/C7/ Wkiol1csv9wr7d7naadwwa-3jew126.png "title=" qq picture 20160506163355.png "alt=" Wkiol1csv9wr7d7naadwwa-3jew126.png "/>First we observe that signal number 1-31 is a common signal, and we are mostly familiar with the signals discussed. 32-33 does not occupy the signal table, represents a differentiated version, 34-64 is a real-time signal. We do not discuss, 1-31 signal we can find his macro definition in signal.h. The number represents the signal number, and the back represents the signal m
); To delete a message queue
6. Inter-process communication-signal
#include
int Kill (pid_t pid,int Sig)
int raise (int signo); process sends signal to itselfRaise (Signo) is equivalent to Kill (Getpid (), signo);
Alarm (2) timed two seconds to produce SIGALRM signal, the system default processing is the end process.
The int pause (void)//pause function causes the calling process to suspend until a signal is caught.
Signal (Sigint,ctrl_c) Ctrl_c fun
the set parameter to the process blocking set sig_unblock This option is in contrast to the feature Sig_block, which indicates that the message that is specified in the thread blocking signal set is deleted sig_setmask This option indicates that the thread Block signal set set directly for your specified set
Set parameter
Indicates the set of signals you specified Oldset
Returns the old block signal set return value int
0 indicates success,-1 failure. 2.2 functions to get the pending signal
The
morning-m "Are you Hungry?"Good morningAre you hungry?Ix. Other Matters(1) Return valueAccording to Unix tradition, program execution returns 0 successfully, otherwise it returns 1.if (err) {Process.exit (1);} else {Process.exit (0);}(2) redirectUnix allows you to use pipe redirection data between programs.$ ps aux | grep ' node 'The script can get the redirected data by listening to the standard input of the date event.Process.stdin.resume ();Process.stdin.setEncoding (' UTF8 ');Process.stdin.
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.