+ if ( !defined $bot_pid ) { # independent.
+ exit 0;
+ }
+ elsif ( $bot_pid == $$ ) { # parent.
+ &status("parent caught SIG$sig (pid $$).") if ( defined $sig );
+
+ &status('--- Start of quit.');
+ $ident ||= 'infobot'; # lame hack.
+
+ &status("Memory Usage: $memusage KiB");
+
+ &closePID();
+ &closeStats();
+
+ # shutdown IRC and related components.
+ if ( &whatInterface() =~ /IRC/ ) {
+ &closeDCC();
+ &seenFlush();
+ &quit( $param{'quitMsg'} );
+ }
+ &writeUserFile();
+ &writeChanFile();
+ &uptimeWriteFile() if ( &IsParam('Uptime') );
+ &sqlCloseDB();
+ &closeSHM($shm);
+
+ if ( &IsParam('dumpvarsAtExit') ) {
+ &loadMyModule('DumpVars');
+ &dumpallvars();
+ }
+ &symdumpAll() if ( &IsParam('symdumpAtExit') );
+ &closeLog();
+ &closeSQLDebug() if ( &IsParam('SQLDebug') );
+
+ &status('--- QUIT.');
+ }
+ else { # child.
+ &status("child caught SIG$sig (pid $$).");