void MythSystemSignalManager::run(void) { RunProlog(); LOG(VB_GENERAL, LOG_INFO, "Starting process signal handler"); while( run_system ) { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 50 * 1000 * 1000; // 50ms nanosleep(&ts, NULL); // sleep 50ms while( run_system ) { // handle cleanup and signalling for closed processes listLock.lock(); if( msList.isEmpty() ) { listLock.unlock(); break; } MythSystemUnix *ms = msList.takeFirst(); listLock.unlock(); // This can happen if it has been deleted already if (!ms) continue; ms->m_parent->HandlePostRun(); if (ms->m_stdpipe[0] > 0) writeThread->remove(ms->m_stdpipe[0]); CLOSE(ms->m_stdpipe[0]); if (ms->m_stdpipe[1] > 0) readThread->remove(ms->m_stdpipe[1]); CLOSE(ms->m_stdpipe[1]); if (ms->m_stdpipe[2] > 0) readThread->remove(ms->m_stdpipe[2]); CLOSE(ms->m_stdpipe[2]); if( ms->GetStatus() == GENERIC_EXIT_OK ) emit ms->finished(); else emit ms->error(ms->GetStatus()); ms->disconnect(); bool cleanup = ms->m_parent->doAutoCleanup(); ms->Unlock(); if( cleanup ) ms->deleteLater(); } } RunEpilog(); }
// spawn separate thread for signals to prevent manager void MythSystemLegacySignalManager::run(void) { RunProlog(); LOG(VB_GENERAL, LOG_INFO, "Starting process signal handler"); while( run_system ) { usleep(50000); // sleep 50ms while( run_system ) { // handle cleanup and signalling for closed processes listLock.lock(); if( msList.isEmpty() ) { listLock.unlock(); break; } MythSystemLegacyWindows *ms = msList.takeFirst(); listLock.unlock(); if (!ms) continue; if (ms->m_parent) { ms->m_parent->HandlePostRun(); } if (ms->m_stdpipe[0]) writeThread->remove(ms->m_stdpipe[0]); CLOSE(ms->m_stdpipe[0]); if (ms->m_stdpipe[1]) readThread->remove(ms->m_stdpipe[1]); CLOSE(ms->m_stdpipe[1]); if (ms->m_stdpipe[2]) readThread->remove(ms->m_stdpipe[2]); CLOSE(ms->m_stdpipe[2]); if (ms->m_parent) { if( ms->GetStatus() == GENERIC_EXIT_OK ) emit ms->finished(); else emit ms->error(ms->GetStatus()); ms->disconnect(); ms->Unlock(); } ms->DecrRef(); } } RunEpilog(); }
void MythSystemSignalManager::run(void) { threadRegister("SystemSignalManager"); LOG(VB_GENERAL, LOG_INFO, "Starting process signal handler"); while( gCoreContext ) { usleep(50000); // sleep 50ms while( gCoreContext ) { // handle cleanup and signalling for closed processes listLock.lock(); if( msList.isEmpty() ) { listLock.unlock(); break; } MythSystemWindows *ms = msList.takeFirst(); listLock.unlock(); ms->m_parent->HandlePostRun(); if (ms->m_stdpipe[0]) writeThread->remove(ms->m_stdpipe[0]); CLOSE(ms->m_stdpipe[0]); if (ms->m_stdpipe[1]) readThread->remove(ms->m_stdpipe[1]); CLOSE(ms->m_stdpipe[1]); if (ms->m_stdpipe[2]) readThread->remove(ms->m_stdpipe[2]); CLOSE(ms->m_stdpipe[2]); if( ms->GetStatus() == GENERIC_EXIT_OK ) emit ms->finished(); else emit ms->error(ms->GetStatus()); ms->disconnect(); ms->Unlock(); if( ms->m_parent->doAutoCleanup() ) delete ms; } } threadDeregister(); }