http://bugzilla.novell.com/show_bug.cgi?id=599698
http://bugzilla.novell.com/show_bug.cgi?id=599698#c4
--- Comment #4 from Michael Andres 2010-05-19 15:25:43 CEST ---
Well, it works most of the time :) But not just zypper will leave things
behind, also libzypp needs a proper exit to cleanup behind.
One alternative is to set just some 'emergency' flag inside the handler, and
clutter up the code with 'ifEmergencyExit()' calls.
void ifEmergencyExit() { if ( emergency ) { Cleanup(); exit(); } }
For an application whithout main event loop this is no fun.
But maybe throwing an exception can help you out.
struct EmergencyExit {};
void signal_handler( int sig )
{
::signal( SIGINT, SIG_IGN );
::signal( SIGTERM, SIG_IGN );
if ( serious )
{
throw EmergencyExit();
}
...
}
int main( int argc, char * argv[] )
{
try
{
if (::signal(SIGINT, signal_handler) == SIG_ERR)
out.error("Failed to set SIGINT handler.");
if (::signal(SIGTERM, signal_handler) == SIG_ERR)
out.error("Failed to set SIGTERM handler.");
...
}
catch ( EmergencyExit )
{
Zypper & zypper = *Zypper::instance();
zypper.cleanup();
exit( ZYPPER_EXIT_ON_SIGNAL );
}
return 0;
}
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.