I compiled the program to start it and wait, I open the other terminal, and kill any running program "kill I kill with "Peed" or "Mar-15 Drink" or "Mar-SigersM PID" (replace PID with actual process ID). Exits the killed program, but can not trace SIGTERM to print "made"
I copy the code here:.
Can I help you? I appreciate all the answers.
#include & lt; Signal.h & gt; # Include & lt; Stdio.h & gt; #include & lt; String.h & gt; # Include & lt; Unistd.h & gt; Volatile sig_atomic_t done = 0; Zero word (int sinum) {done = 1; } Int main (int argc, char * argv []) {struct cigaction action; Memate (and action, 0, saffhoff (straight signage)); Action.sa_handler = Term; Signignation (Sigmeter, and Action, NULL); Int loop = 0; While {(done!) {Int t = sleep (3); / * sleep gives the number of remaining seconds if * interrupted * / while (t> gt;) {printf (% d seconds for going to the loop run , Was finished with ... finishing ... \ n ", t); t = sleep (t);} printf (" loop run% d. \ N ", ending loop ++);} printf (" . \ N "); Return 0;}
The signal handler needs to be set up correctly. This is how I handler my signal ूं:
Fixed in zero handle int (int signum); // in header, then apply // in the source file string signaling transmission; Myaction.sa_handler = handle_signal; Myaction.sa_flags = 0; // or whatever flags you want but do it here so that the signals you enter can see the flag sigset_t mask; sigemptyset (& mask); signets (and mask, SIGTERM); signation (signaturem, and Malion, tap); Myaction.sa_mask = Mask; I am able to capture SIGTERM I also register all other signals along with ( sigaddset and sigaction ).
No comments:
Post a Comment