Linux Semaphore two

Source: Internet
Author: User
Tags sigint signal terminates

Today, I met a sighup question, and then I went over it again:

Some signals are handled by default to "Terminate +core", where the core indicates that when the process terminates, a core file is produced in the current working directory of the process, which is a snapshot of the memory at the end of the process so that it can be tried later for debugger.

Core files are not produced in the following cases:

(1) Set the Set-user-id for the program and the user is not the owner of the program;

(2) Set the Set-group-id for the program and the user is not the group owner of the program;

(3) The process does not have write permission under the current working directory;

(4) The current working directory has a core file and the process does not have write access to the core file;

(5) The core file is too large.

Various signal generation conditions and default processing methods are described below:

SIGABRT default processing: Terminates +core, which is generated when the program calls the Abort function. The program terminates abnormally.

SIGALRM default processing: Terminates, which is generated when the timer set by the alarm or setitimer function times out.

Sigbus default processing: Terminate +core, often due to memory errors generated by this signal.

SIGCHLD default processing: ignore; When the process terminate or stopped, the signal is sent to the parent process. If the parent process needs to know when the child process terminates, the parent process must capture the signal. Wait or waitpid is usually called in the capture function of the signal to get the PID and termination state of the child process.

Sigcont default processing: Ignore/Continue, when the job control command process continues execution, the signal is sent to the process. If the process has been stopped before, the signal is handled by default to continue the execution of the process; otherwise, the signal is ignored.

SIGFPE Default processing: Terminates the +core and generates the signal when an arithmetic error occurs (e.g., except 0, overflow, etc.).

SIGHUP default processing: termination; When the terminal interface detects a connection disconnection, the kernel sends the signal to the session leader process with the control terminal (the signal is sent only if the terminal's clocal identity bit is not set). The session leader receiving the signal may be the background process, which is different from the signal generated by the normal terminal, and the receiver of the normal terminal signal is the foreground process group. Additionally, when the session leader of the control terminal is terminated, the sighup signal is sent to the foreground process group. Because the daemon does not control the terminal, it should not normally receive the signal, so this signal is often used as a signal for the daemon to reread the configuration file.

Sigill default processing: Terminates, and generates the signal when the processor executes an illegal instruction.

SIGINT default processing: termination, when the terminal key (Control+c or delete) is entered into the terminal, the terminal generates a SIGINT signal. The signal is sent to the foreground process group. Typically used to terminate a process that is already running.

SIGIO Default processing: Terminate/ignore; this signal is used to provide asynchronous IO mode. When an IO is available, the signal is generated to notify the process.

SIGKILL default processing: terminate; this signal gives the superuser the ability to terminate any process, usually through the kill function or command. The signal cannot be ignored or captured.

Sigpipe default processing: Terminates, which is generated when the data is written to a pipe that has been closed to the reader. This signal is also generated when writing data to a socket of the Sock_stream type that is not connected.

Sigpoll default processing: Terminates, which is generated when the specified event occurs on a selectable device.

Sigprof Default processing mode: Terminate, the interval timer set by Setitimer time-out will produce this signal.

SIGPWR default processing: termination, when the system has a UPS (uninterruptible power supply, that is, battery), when the battery is powered off, when the battery low, it will generate the signal to notify the process to shut down within 1530 seconds.

Sigquit default processing: Terminate +core, when the input exit key (control+\), the terminal will generate a sigquit signal, the signal is transmitted to the foreground process group.

SIGSEGV default processing: terminates +core; the signal is generated when an illegal memory reference is used.

SIGSTOP default processing: Stop process, job control signal, used to stop the process. The signal cannot be ignored or captured.

Sigsys Default processing: Terminates the +core and generates the signal when an illegal system is called.

SIGTERM default processing: Terminate; Kill function sends the signal by default to terminate the process.

SIGTRAP default processing: terminating +core; system-defined hardware errors. Typically, when you encounter a debug breakpoint, you pass control to debugger.

SIGTSTP default processing: Stops the process, and when the input suspend key (CONTROL+Z), the terminal produces the (interactive stop) signal to stop the process. The signal is sent to the foreground process group.

Sigttin default processing: Stops the process, which is generated when a process in the background process group requires the data to be read from the control terminal. There are two exceptions: 1, a background process that requires read data ignores or blocks the signal, 2, the process belongs to the process group is "orphan". In both cases, the signal is not generated, otherwise read returns incorrectly and the errno is set to Eio.

Sigttou default processing: Stops the process, which is generated when processes in the background process group require that the data be written to the control terminal. Background processes can be allowed to write data to the control terminal. When a background process is not allowed to write data to the control terminal, write returns incorrectly, and errno is set to Eio. There are two exceptions: 1, a background process that requires write data ignores or blocks the signal, 2, the process belongs to the process group is "orphan". In both cases, the signal is not generated.

Sigurg default processing: ignore; This signal is generated when the network connection (Socket) receives out-of-band (Out-of-band data).

SIGUSR1 default processing: Terminate; user-defined signal.

SIGUSR2 default processing: Terminate; user-defined signal.

SIGVTALRM default processing: Terminate, the signal is generated when the virtual timer set by Setitimer times out.

SIGXCPU Default processing: Terminates the +core/ignore, the signal is generated when the process exceeds the soft limit of the CPU.

Sigxfsz Default processing: Terminates the +core/ignore, the signal is generated when the process exceeds the soft limit of the file size.

Cause, someone used the Ruby Telnet module to complete a Windows-side automated test, the script is not finished logout cause some programs
It's always strange to die; but not all calls are subject, as if only the last call except the problem, and Telnet.cmd ("script")
It should be a blocking type Ah, how the script did not finish logout execution, too tmd strange; it could be a problem with the script, next week.
Check the script code.
Require ' net/telnet ' # connected to the remote host foobartelnet = Net::telnet.new ("host" = "Foobar") {|c| print C} # Login Telnet.login ("your Name "," Your password ") {|c| print c}# wait for prompt after login (" ls ") {telnet.cmd print |c| execute command and wait for hint # Slightly more complicated example c}# (" Sleep 5 &  & Echo Foobar & ") {|c| print C} stdout.flush # <-If not, it is hard to see that the program has run to here # Wait for the output of the preceding command telnet.waitfor (/foobar\z/) {|c| print C} # End login session telnet.cmd ("Exit") {|c| print C}telnet.close

Linux Semaphore two

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.