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


Signal problems

Code like the following procedures : the function is the start of the process of building elements in the process of installing signals son, and then wait by the signal (ctrl+z), the son continued the process, after the father returned to the process cycle again. But implementation, the first one after the acceptance of ctrl+z, after ctrl+z no response, but even ctrl+c not withdraw from the process, changed some help

[code]
Int g_flg = 0
Int g_exit_flg = 0
Main ()
{
Pid = fork ();

While (g_exit_flg==0) (
If (pid<0) (
Printf ( "fork () error\n");
Exit (-1);
) Else if (pid>;0) (process 4003rd father
Wait (&status);
Printf ( "End parent task.\n");
Exit (-1);
) Else if (pid==0) (
Init_sig ();

While (g_flg==0) (
Pause ();
                        }

Printf ( "Child\n");
                }
        }
Exit (1);
}

Int int_sig () (
Struct sigaction act;

Act.sa_handler = quit_action;
Act.sa_flags = 0
Sigemptyset (&act.sa_mask);
Sigaction (SIGHUP, &act, NULL);
Sigaction (SIGINT, &act, NULL);
Sigaction (SIGQUIT, &act, NULL);
Sigaction (SIGILL, &act, NULL);
Sigaction (SIGTERM, &act, NULL);
       
Act.sa_handler = SIG_IGN;
Act.sa_flags = 0
Sigemptyset (&act.sa_mask);
Sigaction (SIGPIPE, &act, NULL);

Act.sa_flags = 0
Act.sa_handler = alm_sig_action;
Sigemptyset (&act.sa_mask);
If (sigaction (SIGTSTP, &act, NULL) ====== -1) (4003rd Ctrl + z
Printf ( "sigaction error.\n");
Return NG;
        };
Return lounges
}
Void alm_sig_action () (
G_flg = 1;

}

Void quit_action () (
G_exit_flg = 1;
Exit (1);
}
[/code]

Signal problems

No problem with the procedure you need to note is that although you can catch SIGTSTP signal, but you can not stop the process on the background of your shell, therefore, in accordance with ctrl+z you after your procedure has been unable to receive a signal ctrl+c.

Signal problems

No wonder each time the output will be :
[5] Stopped ssg
This information, thank you



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