/** * Helper method performing shutdown. */ void shutdown() { // stop main loop and all dependent components if (s_mainLoop != NULL) { delete s_mainLoop; s_mainLoop = NULL; } if (s_messageMap!=NULL) { delete s_messageMap; s_messageMap = NULL; } // free templates for (map<string, DataFieldTemplates*>::iterator it = templatesByPath.begin(); it != templatesByPath.end(); it++) { delete it->second; } templatesByPath.clear(); // reset all signal handlers to default signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGTERM, SIG_DFL); // delete daemon pid file if necessary closePidFile(); logNotice(lf_main, "ebusd stopped"); closeLogFile(); exit(EXIT_SUCCESS); }
int PidFile::testAndRelockPidFile( const char * pPidFile, int pid ) { struct stat st; if (( nio_stat( pPidFile, &st ) == -1 )|| ( st.st_mtime != m_stPid.st_mtime )|| ( st.st_size != m_stPid.st_size )|| ( st.st_ino != m_stPid.st_ino )) { closePidFile(); int ret = lockPidFile( pPidFile ); if ( !ret ) ret = writePid( pid ); return ret; } return 0; }