[Box Backup-commit] #67: Add mutexes for Win32 (client) to enable detection of running instance during install/uninstall

Box Backup trac at boxbackup.org
Tue Mar 30 15:50:56 BST 2010

#67: Add mutexes for Win32 (client) to enable detection of running instance
during install/uninstall
 Reporter:  achim        |       Owner:  chris   
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:          
Component:  bbackupd     |     Version:  trunk   
 Keywords:               |  

Comment(by achim):

 An improved version that allows for Box Backup/Boxi detection (again,
 *not* limitation) across different users:
   /* Creates the two mutexes checked for by the installer/uninstaller to
 see if
   the program is still running.
   One of the mutexes is created in the global name space (which makes it
   possible to access the mutex across user sessions in Windows XP); the
   is created in the session name space (because versions of Windows NT
   to 4.0 TSE don't have a global name space and don't support the
 void CreateMutexes(string)

  /* By default on Windows NT, created mutexes are accessible only by the
     running the process. We need our mutexes to be accessible to all
 users, so
     that the mutex detection can work across user sessions in Windows XP.
     do this we use a security descriptor with a null DACL.

  SetSecurityDescriptorDacl(&SecurityDesc, TRUE, NULL, FALSE);
  SecurityAttr.nLength = sizeof(SecurityAttr);
  SecurityAttr.lpSecurityDescriptor = &SecurityDesc;
  SecurityAttr.bInheritHandle = FALSE;
  CreateMutex(&SecurityAttr, FALSE, TEXT(MutexName));
  CreateMutex(&SecurityAttr, FALSE, TEXT('Global\' + MutexName));

 call this function like this:

 int main(int argc, const char *argv[])
         int returnCode = 0;

         #ifdef WIN32

Ticket URL: <https://www.boxbackup.org/trac/ticket/67#comment:5>
Box Backup <http://www.boxbackup.org/>
An open source, completely automatic on-line backup system for UNIX.

More information about the Boxbackup-commit mailing list