Enhanced process control for jt9 executable

The wsjtx  process creates control  files .start, .stop, or  .quit and
the jt9  process deletes  them.  This  is intended  to avoid  any race
conditions that get the processes out of sync.
This commit is contained in:
Bill Somerville
2020-03-14 00:01:54 +00:00
parent ebf4952c7c
commit 523e9a1a07
3 changed files with 21 additions and 43 deletions
+6 -31
View File
@@ -1041,8 +1041,8 @@ void MainWindow::on_the_minute ()
void MainWindow::pause_jt9 ()
{
// Create .lock so jt9 will wait
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
// Create .stop so jt9 will wait
QFile l {m_config.temp_dir ().absoluteFilePath (".stop")};
if (!l.open(QFile::ReadWrite))
{
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
@@ -1051,21 +1051,11 @@ void MainWindow::pause_jt9 ()
void MainWindow::release_jt9 ()
{
// Remove .lock so jt9 will continue
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
while (l.exists ())
// Create .start so jt9 will continue
QFile l {m_config.temp_dir ().absoluteFilePath (".start")};
if (!l.open(QFile::ReadWrite))
{
if (!l.remove ())
{
if (MessageBox::Cancel == MessageBox::query_message (this
, tr ("IPC Error")
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
, QString {}
, MessageBox::Retry | MessageBox::Cancel))
{
break;
}
}
MessageBox::warning_message (this, tr ("Error creating \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ()));
}
}
@@ -1108,21 +1098,6 @@ void MainWindow::stop_jt9 ()
}
}
void MainWindow::cleanup_jt9 ()
{
// Remove .quit as no longer needed
QFile l {m_config.temp_dir ().absoluteFilePath (".lock")};
while (l.exists ())
{
if (!l.remove ())
{
MessageBox::query_message (this
, tr ("Error removing \"%1\" - %2").arg (l.fileName ()).arg (l.errorString ())
, tr ("Click OK to retry"));
}
}
}
//--------------------------------------------------- MainWindow destructor
MainWindow::~MainWindow()
{