/** * @File : exo_02.cxx * * @Author : A. B. Dragut * * @Synopsis : restauration automatique du traitant par defaut pour * tous les signaux (sauf temps reel) * **/ #include #include #include // _sys_siglist #include #include // setw() #include #include "CExc.h" #include "nsSysteme.h" using namespace nsSysteme; // Signal() using namespace std; namespace { void Derout (int NumSig) { cout << "Signal " << _sys_siglist [NumSig] << " recu numero : " << NumSig << endl; cout << " qui maintenant sera automatiquement mis au traitement par defaut.\n"; } // Derout() } // namespace anonyme int main(int argc, char * argv []) { try { if (1 != argc) throw CExc ("main()",string ("Usage : ") + argv [0]); for (int NumSig = 1; NumSig < CstSigMax; ++NumSig) { if(NumSig != SIGKILL && NumSig != SIGSTOP) { struct sigaction Action; Action.sa_flags = SA_RESETHAND; Action.sa_handler = Derout; sigemptyset (& Action.sa_mask); Sigaction (NumSig, &Action, 0); cout << "Signal numero " << setw(2) << NumSig << " signifiant " << _sys_siglist [NumSig] << " deroute, traitement Particulier," << " et restoration automatique au traitement par defaut\n"; } else { cout << "Omettant le signal " << _sys_siglist [NumSig] << "\n"; } } cout << "Deroutement acheve.\n"; for (;;); return 0; } catch (const CExc & Exc) { cerr <