const wxString& path)
{
wxASSERT_MSG( !m_impl,
- _T("calling wxSingleInstanceChecker::Create() twice?") );
+ wxT("calling wxSingleInstanceChecker::Create() twice?") );
// must have the file name to create a lock file
- wxASSERT_MSG( !name.empty(), _T("lock file name can't be empty") );
+ wxASSERT_MSG( !name.empty(), wxT("lock file name can't be empty") );
m_impl = new wxSingleInstanceCheckerImpl;
fullname = wxGetHomeDir();
}
- if ( fullname.Last() != _T('/') )
+ if ( fullname.Last() != wxT('/') )
{
- fullname += _T('/');
+ fullname += wxT('/');
}
fullname << name;
return m_impl->Create(fullname);
}
-bool wxSingleInstanceChecker::IsAnotherRunning() const
+bool wxSingleInstanceChecker::DoIsAnotherRunning() const
{
- wxCHECK_MSG( m_impl, false, _T("must call Create() first") );
+ wxCHECK_MSG( m_impl, false, wxT("must call Create() first") );
+
+ const pid_t lockerPid = m_impl->GetLockerPID();
+
+ if ( !lockerPid )
+ {
+ // we failed to open the lock file, return false as we're definitely
+ // not sure that another our process is running and so it's better not
+ // to prevent this one from starting up
+ return false;
+ }
// if another instance is running, it must own the lock file - otherwise
// we have it and the locker PID is ours one
- return m_impl->GetLockerPID() != getpid();
+ return lockerPid != getpid();
}
wxSingleInstanceChecker::~wxSingleInstanceChecker()