|
From: Josue A. G. <jos...@gm...> - 2012-11-13 11:35:15
|
On Tue, Nov 13, 2012 at 9:26 AM, Cristiano Sumariva <sum...@gm...>wrote: > Maybe is trying to say that he needs only one instance running. > > Inter Process Communication? > > An alternative if shared memory is available is to write some value at an > shared scope. > Then each new program instance should check if this global value( magic > number ) exists then the second instance should abort or terminate( signal > on pthreads? ) the second running program. > Write the PID and program name at shared scope and each new instance > should check those values are still valid. > > Your application will write files, so can not you write a pid file? > > Some socket pipe stuff? > > > The canonical way of "one instance only" check on Win32 is to create a named mutex (CreateMutex) and check the error (GetLastError) for ERROR_ALREADY_EXISTS. josue josuegomes.com |