_Core file transmission and reception of signals _ signal

Signal transmission and reception

(1) Send

  In general, most of the causes of the transmitted signal, because of certain events kernel, hardware occurs, the event dedicated signal will be sent to a process, the process of telling the incident occurred.

  But for our own writing process, in fact, more of a received signal, rather than sending a signal.

  Our own reason is nothing more than send a signal following situations:

  (A) Ctrl + C, Ctrl + \ to send a signal to terminate running processes

  (B) execute the kill command to send a command signal to terminate runaway processes, usually send this signal 15

    15 name of this signal is SIGTERM, TERM is the abbreviation terminal, in fact, the meaning of the command-line terminal.

    When not using the Ctrl + C, Ctrl + \ when to terminate the process, often using the Kill command to terminate the process.

    So what kind of process would use Ctrl + C, Ctrl + \ to terminate it?

    Only when the process was holding the command-line terminal, you can use Ctrl + C, Ctrl + \ to terminate.

  (C) for some special needs, often in our own procedures which you need to call the kill function to send a signal to another process.

    What special needs?

      For example, process A and B processes need to work together, A process corresponding time you are ready, may need to send a signal to the B process, notification process B, after the B process receives a signal, you know that the event is ready to be in line with A the process of doing things.

    As for their own writing process to send a signal of what is better?

      In fact, what kind of signal transmission will do, but we say that almost every kind of signal has its own specific purpose.

      So in our own program sends a signal that if people dedicated time signals sent to it, so it is very formal, and is likely to cause misunderstanding. For example, my A process to another process to send a SIGSEGV signal, B thought process pointer error event occurs, time is actually not a pointer error occurred, but other events, which resulted in the wrong understand.

    Therefore, the process calls himself kill function to send a signal we can send that SIGUSER1, SIGUSER2 two custom signal, the so-called custom is, the signal event represents, may be specified by the programmer to the actual situation.

(2) receiving

  For our own writing process, the most common operation signal or receive signal. But in general, we are not going to re-process and set of signal processing mode, but the default processing mode signal to signal processing.

  Although very few treatment reset signal, but there are always such a demand, so we will be back on, how to call API reset signal handling.

(3) core file

  1) What is the core document

  For program storage (process) at the end of the current moment, the process of code and data in memory, core file can be used to analyze the situation at the end of the process, but because the process code and data are binary, so the core When the file is opened directly we do not understand, generally require special software to read the translation.

  2) Not all signals are generated core file when the process is terminated

  Only certain signal will be generated at the time of termination of core documents, but under normal circumstances and does not create this file, because the system will have a default setting to shut down the core, the core file will be saved only open after this setting.

  So you see the prompt core dumped, this time to identify this signal to terminate the process, producing a core file, but due to the closure of the set, so the core file is discarded, dumped is discarded meaning.

  Show

    Examples 1: Ctrl + \ transmission signal SIGQUIT

    Example 2: Operation Address Error

  3) If you do not want to discard the core document how to do?

  The relevant file system can be set up, core files are generally saved by default in the current path.

  Since the core in the actual development less than basic (unless some special occasions), so we are no longer here insight into core file.

Guess you like

Origin www.cnblogs.com/doitjust/p/12622633.html