StandaloneStartup.st
changeset 11106 740c42559ef7
parent 11105 4deedf531f75
child 11107 2c1b779bc57a
equal deleted inserted replaced
11105:4deedf531f75 11106:740c42559ef7
   197 
   197 
   198 isAnotherApplicationInstanceRunning
   198 isAnotherApplicationInstanceRunning
   199     "answer true, if another instance of mzself is currently running.
   199     "answer true, if another instance of mzself is currently running.
   200      For now, it only works under win32, because it uses the underlying mutex mechanism."
   200      For now, it only works under win32, because it uses the underlying mutex mechanism."
   201     
   201     
   202     | lastErrorCode alreadyExists handleAndLastErrorCode verboseTmp |
   202     | lastErrorCode alreadyExists handleAndLastErrorCode |
   203 
   203 
   204     OperatingSystem isMSDOSlike ifTrue:[
   204     OperatingSystem isMSDOSlike ifTrue:[
   205         verboseTmp := Verbose.              
       
   206         Verbose := true.                    "/ fix for weird bug in expecco which requires Verbose activated
       
   207         handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString).
   205         handleAndLastErrorCode := OperatingSystem createMutexNamed: (self applicationUUID printString).
   208         MutexHandle := handleAndLastErrorCode first.
   206         MutexHandle := handleAndLastErrorCode first.
   209         lastErrorCode := handleAndLastErrorCode second.
   207         lastErrorCode := handleAndLastErrorCode second.
   210         "/ self assert: lastErrorCode == 0.
   208         "/ self assert: lastErrorCode == 0.
   211         alreadyExists := 
   209         alreadyExists := 
   212             MutexHandle isNil 
   210             MutexHandle isNil 
   213             or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
   211             or:[lastErrorCode == 183 "ERROR_ALREADY_EXISTS"
   214             or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
   212             or:[lastErrorCode == 5 "ERROR_ACCESS_DENIED"]].
   215         Verbose := verboseTmp.
       
   216 
   213 
   217         alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle].
   214         alreadyExists ifFalse:[OperatingSystem waitForSingleObject: MutexHandle].
   218         ^ alreadyExists
   215         ^ alreadyExists
   219     ].
   216     ].
   220 
   217 
   520 ! !
   517 ! !
   521 
   518 
   522 !StandaloneStartup class methodsFor:'documentation'!
   519 !StandaloneStartup class methodsFor:'documentation'!
   523 
   520 
   524 version
   521 version
   525     ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.14 2008-08-04 14:27:35 fm Exp $'
   522     ^ '$Header: /cvs/stx/stx/libbasic/StandaloneStartup.st,v 1.15 2008-08-05 07:55:12 fm Exp $'
   526 ! !
   523 ! !
   527 
   524 
   528 StandaloneStartup initialize!
   525 StandaloneStartup initialize!