Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Linux signal takeover not signal master guiding

Linux programming, the signal transfer function, but surprisingly failed to take over SIGINT signals.

Gdb debugging primitive procedures, the implementation of the function of signal transmission SIGINT signal to the debugging process, but I did not take over the proceedings.
In addition to the main program, I use the sleep.

Later, I wrote the following test procedure, and the original structure of the same code. But gdb debugging time, the signal unexpectedly successful takeover. Depressed, not positioning.
Ask the experts, this is no less than a signal to take over experience? Please give pointers to one.


Following is the test procedure similar to the original code.
[code]
#include "Unistd.h>;
#include "Stdlib.h>;
#include "String>;
#include "Iostream>;



Bool = false; //! gv_MainStarted it has activated the main program

#include "Fcntl.h>;
#include "Signal.h>;
#include "String.h>;
#include "Assert.h>;
#include "Memory.h>;
#include "Errno.h>;
#include "Sys/stat.h>;


#ifdef __OS_UNIX__
#include "Xol.h" //! used by the Treasury paper, the use of Unix
#endif //__OS_UNIX__
Using namespace std;

//! Signal Processing
Void signal_process (int sig_id)
{
Cout "" "sig_id :" "<sig_id" <endl;
   
Cout "" gv_MainStarted "<endl;
   
Switch (sig_id)
    {
Case SIGINT :
If (!gv_MainStarted)
Exit (0);
Cout "" "SIGINT stop," "<endl;
Break;
SIGTERM case :
If (!gv_MainStarted)
Exit (0);
Cout "" "SIGTERM stop," "<endl;
Break;
SIGSTOP case :
If (!gv_MainStarted)
Exit (0);
Cout "" "SIGSTOP stop," "<endl;
Break;
SIGCONT case :
If (!gv_MainStarted)
Exit (0);
Cout "" "SIGCONT stop," "<endl;
Break;
    }
Signal (sig_id, signal_process);
}


Int main (int argc, char* argv[])
{

   
Signal (SIGTERM, signal_process);
Signal (SIGINT, signal_process);
Signal (SIGSTOP, signal_process);
Signal (SIGCONT, signal_process);
   
Gv_MainStarted = true;
   

Signal (SIGTERM, signal_process);
Signal (SIGINT, signal_process);
Signal (SIGSTOP, signal_process);
Signal (SIGCONT, signal_process);
Int Rifa
For (i = 1;i "2; i = 1)
        {
Sleep (3);
        }
Return 0
}

[/code][/quote]-->-->

Linux signal takeover not signal master guiding

You always changed its procedures in the process of the group? The change also could not SIGINT signal;

Another SIGINT signal is not reliable, because
Call again and enter your signal_process signal_process SIGINT signals between the procedures you will not be caught.
During the SIGINT signal will be transmitted directly to init system daemon,
As guardian of init process for dealing with the tacit consent of SIGINT is the process which led to the termination of the current process from you.
Covault dealt with the worst alternative is to import raw, it is judged by getch Covault

SIGINT is not reliable on the other, see the following examples :
-->

Linux signal takeover not signal master guiding

I was not able to test your procedures.
But you do not know SIGSTOP signals can be trapped or ignored?

Linux signal takeover not signal master guiding

I tested, effective! ! ! The results are as follows :
Sig_id : 2
1
Covault stop
Sig_id : 2
1
Covault stop
Sig_id : 2
1
Covault stop
Sig_id : 2
1
Covault stop
Sig_id : 2
1
Covault stop

Linux signal takeover not signal master guiding

On the writing test code can be. But the actual code is not acceptable, I ah.
I would like to ask the experts have not encountered such a situation. . .

-->



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com