The management signal of C ++ in LINUX-general Linux technology-Linux programming and kernel information. The following is a detailed description. Every time a process executes an annoying action, so that Linux? When the kernel sends a signal, the signal must be processed. Signal processing programs usually release some important resources and terminate applications. In this case, all the object instances on the stack are in the undamaged state. On the other hand, if these signals are converted to C ++ exceptions, You can elegantly call their constructor and arrange multi-layer catch blocks to better process these signals.
The SignalExceptionClass defined in Listing 2 provides an abstraction of the C ++ exception that represents a possible signal from the kernel. SignalTranslator is a template class based on SignalExceptionClass, which is usually used to implement conversion to C ++ exceptions. At any moment, only one signal processing program can process one signal of an active process. Therefore, SignalTranslator adopts the singleton design mode. The overall concept is presented through the SegmentationFault class for sigsegv and the FloatingPointException class for SIGFPE.
Listing 2. Converting signals to exceptions