diff --git a/ChangeLog b/ChangeLog index be2e3179..dcec0f20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21776,3 +21776,5 @@ * Cleaned up a compile warning in 'lib/rdevent_line.cpp'. 2021-06-01 Fred Gleason * Cleaned up compile warnings in 'lib/rdformpost.cpp'. +2021-06-01 Fred Gleason + * Cleaned up compile warnings in 'lib/rdinstancelock.cpp'. diff --git a/lib/rdinstancelock.cpp b/lib/rdinstancelock.cpp index 6b728309..00f77e96 100644 --- a/lib/rdinstancelock.cpp +++ b/lib/rdinstancelock.cpp @@ -2,7 +2,7 @@ // // An abstract instance-locking class. // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2021 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License @@ -26,9 +26,10 @@ #include #include -#include -#include +#include +#include +#include #include RDInstanceLock::RDInstanceLock(QString path) @@ -58,7 +59,11 @@ bool RDInstanceLock::lock() lock_locked=false; return false; } - fscanf(file,"%d",&pid); + if(fscanf(file,"%d",&pid)!=1) { + rda->syslog(LOG_WARNING, + "RDInstanceLock::lock fscanf returned a parser failure [%s]", + strerror(errno)); + } fclose(file); dir.setPath(QString().sprintf("/proc/%u",pid)); if(!dir.exists()) { diff --git a/rdairplay/rdairplay.cpp b/rdairplay/rdairplay.cpp index 7e4665ce..4ed8b2a7 100644 --- a/rdairplay/rdairplay.cpp +++ b/rdairplay/rdairplay.cpp @@ -53,16 +53,6 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) air_panel=NULL; - // - // Ensure Single Instance - // - air_lock=new RDInstanceLock(RDHomeDir()+"/.rdairplaylock"); - if(!air_lock->lock()) { - QMessageBox::information(this,tr("RDAirPlay"), - tr("Multiple instances not allowed!")); - exit(1); - } - // // Get the Startup Date/Time // @@ -77,6 +67,16 @@ MainWidget::MainWidget(RDConfig *config,QWidget *parent) exit(1); } + // + // Ensure Single Instance + // + air_lock=new RDInstanceLock(RDHomeDir()+"/.rdairplaylock"); + if(!air_lock->lock()) { + QMessageBox::information(this,tr("RDAirPlay"), + tr("Multiple instances not allowed!")); + exit(1); + } + // // Read Command Options //