From the previous articles in my blog, it has been emphasized that the operating system is a multi-process collaborative operation to achieve the logical purpose of the entire operating system, to achieve an artificially manipulated system:The previous blog post has been describing process control, communication between processes, and thread control and manipulation, but it has not been described how multiple processes communicate with each other to inform the entire system. For many different p
signal, the system restores the current signal set to its original, and then calls the handler function.
Stevens in the Advanced Programming for UNIX environment. "If a signal is caught and if the signal handler returns, then Sigsuspend returns and the SIG Nal Mask of the "process is" set to its value before the called to Sigsuspend. "Because the Sigsuspend is atomic operation, so this is the feeling of the first call signal handler Return first, then sigsuspend back.
int main (void) {sigset
Becoming a Senior Programmer proficient in Linux programming has always been the goal of many friends. According to statistics from chinacache, the monthly salary of Linux programmers in Beijing is 1.8 times that of Windows programmers, 2.6 times that of Java programmers, and 2.9 times that of Windows programmers. At the same time, the data shows that with the increase of work experience, the income gap bet
parent process.
SIGINT
When a user presses the interrupt key (usually Ctrl + C), the kernel sends this signal to all processes associated with the terminal. It provides a simple way to stop running programs.
SIGQUIT
This signal is very similar to SIGINT. When you press the return key (ASCII code FS, usually Ctrl + \), the kernel sends this signal. SIGQUIT will form an abnormal termination described by POS
Signal ClassificationUnreliable signals VS. Reliable SignalsThe Linux signaling mechanism is basically inherited from Unix systems. The signaling mechanism in the early Unix system was relatively simple and primitive, and later exposed some problems in practice, and its main problems were:1. Each time the process processes the signal, the response to the signal is set to the default action. In some cases, it will cause error handling of the signal, so
SA_RESTART --------------------------------------- set the SA_RESTART attribute of the signal S. if the system call is interrupted by the signal S, when the signal processing function returns, the system call is automatically restored. # include lt; signal. h gt; # include lt; stdio. h gt; # include
SA_RESTART-----------------------------------------Set the SA_RESTART attribute of the signal S. if the system call is interrupted by the signal S, after the signal processing function returns,T
process PID
7, Kill,killallFor people with Linux C programming experience, we know that one of the ways of IPC communication is through the semaphore (signal), so for the kill and Killall commands, they have a lot to do with the semaphore, or kill, The Killall command allows us to manually pass signals to the process to control the process by signaling the semaphore.The common semaphore is as follows:
[Email protected] ~]# kill-l
1) SIGHUP
LAST,LASTB (1) Linux System Administrator ' s Manual LAST,LASTB (1)NAMELast, lastb-show listing of the last logged in usersSynopsisLast [-R] [-num] [-N num] [-adfiowx] [-f file] [-t YYYYMMDDHHMMSS] [name ...] [TTY ...]LASTB [-R] [-num] [-N num] [-f file] [-adfiowx] [name ...] [TTY ...]DESCRIPTIONLast searches back through the file/var/log/wtmp (or the file designated by THE-F flag) and displays a list of all us ERs logged in (andOut) Since this file w
, sigxfszBy default, the process exits with the following signals: sigalrm, sighup, SIGINT, sigkill, sigpipe, sigpoll, sigprof, sigsys, sigterm, SIGUSR1, sigusr2, and sigvtalrm.By default, the signal that causes the process to stop is: sigstop, sigtstp, sigttin, sigttouSignals ignored by default include sigchld, sigpwr, sigurg, and sigwinch.
In addition, sigio exits in svr4 and is ignored in 4.3bsd; sigcont continues when the process is suspended; oth
(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 encapsulationintMysignal (intSignvoid(*func) (int)){ structsigaction act,oact; //Incoming callback f
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
number =%d\n", WSTOPSIG(status));//如果cmdstring被信号暂停执行,取得信号值
24
}
To get a description of the return value of the child process refer to another article: http://my.oschina.net/renhc/blog/35116The system () function is easily error-prone, returns too many values, and the return value can easily be confused with the command's return value. It is recommended to use the Popen () function instead, and the simple use of the Popen () function can also be view
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 function name: Signal processing function is invoked after signal is emitted
7. Signal Set function Group blocking signal
The definition of the data structure of the signal set, sigset_t is the type of the structural body
sigset_t Intmask;
Sigemptyset (intmask);
Sigaddset (intmask,
used by the process and the time of the system call.
Utility Timer Expiry
Terminate
Sigwinch)
emitted when the window size changes.
Control terminal window Size change
Ignore
) SIGIO
The file descriptor is ready to start the input/output operation.
asynchronous I/O events
Terminate
SIGPWR)
Power failure
Power
Terminate
Sigsys)
An illegal system call.
The process attempted to
keys can signal to the foreground process, such as ctrl-c means that sigint,ctrl-represents sigquit.Each process is able to access its control terminal via a special device file,/dev/tty.In fact, each terminal equipment is corresponding to a different device file,/dev/tty provides a common interface. A process to access its control terminal can be through the/dev/tty can also be through the device of the corresponding equipment files to access. The T
The init process number is 1 (ps-aux | Less), it can be seen from this point that the INIT process is the starting point for all processes in the system, and Linux starts to run the INIT program after it completes the kernel boot.The INIT program needs to read the configuration file/etc/inittab. Inittab is a non-executable text file that consists of several lines of instructions.Understanding RunLevel:RunLevel is used to represent the system state aft
command's return result is obtained using the wifexited related macro; failure returns-1, We can use the Perro () function or the strerror () function to get useful error information.This article deals only with the simple use of the system () function, and does not talk about the effects of SIGCHLD, SIGINT, and Sigquit on system () functions, and in fact, this article was written today because the system was used by someone in the project () The fun
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.