add terminate action

This commit is contained in:
2025-06-15 22:16:34 +02:00
parent 1ceffa56f8
commit a0c842d90d
4 changed files with 46 additions and 3 deletions

View File

@ -197,6 +197,12 @@ void reHDD::ThreadUserInput()
handleESC();
ui->updateTUI(&listDrives, u8SelectedEntry);
break;
case TUI::UserInput::Terminate:
cout << "Terminate" << endl;
stopShredAllDrives(&listDrives);
sleep(5); // sleep 5 sec
std::exit(1); // Terminates main, doesn't wait for threads
break;
default:
break;
}
@ -464,6 +470,34 @@ void reHDD::startShredAllDrives(list<Drive> *plistDrives)
mxDrives.unlock();
}
/**
* \brief stop shred for all drives
* \param pointer of list <Drive>* plistDrives
* \return void
*/
void reHDD::stopShredAllDrives(list<Drive> *plistDrives)
{
list<Drive>::iterator it;
mxDrives.lock();
for (it = plistDrives->begin(); it != plistDrives->end(); ++it)
{
if (it->state == Drive::SHRED_ACTIVE || it->state == Drive::DELETE_ACTIVE)
{
it->state = Drive::NONE;
Logger::logThis()->info("Abort-Shred-Signal for: " + it->getModelName() + "-" + it->getSerial());
// task for drive is running --> remove selection
}
#ifdef LOG_LEVEL_HIGH
ostringstream address;
address << (void const *)&(*it);
Logger::logThis()->info("Started shred (all) for: " + it->getModelName() + "-" + it->getSerial() + " @" + address.str());
#endif
}
mxDrives.unlock();
}
/**
* \brief print drives with all information
* \param pointer of list <Drive>* plistDrives