Index: trunk/src/helpers/apps.c
===================================================================
--- trunk/src/helpers/apps.c	(revision 77)
+++ trunk/src/helpers/apps.c	(revision 78)
@@ -102,4 +102,5 @@
  *
  *@@added V0.9.4 (2000-08-02) [umoeller]
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
@@ -156,4 +157,5 @@
  *
  *@@added V0.9.4 (2000-07-19) [umoeller]
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
@@ -196,8 +198,9 @@
  *@@added V0.9.4 (2000-07-19) [umoeller]
  *@@changed V0.9.12 (2001-05-21) [umoeller]: fixed memory leak
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
 PSZ* appFindEnvironmentVar(PDOSENVIRONMENT pEnv,
-                            PSZ pszVarName)
+                           PSZ pszVarName)
 {
     PSZ *ppszRet = 0;
@@ -272,4 +275,5 @@
  *@@changed V0.9.12 (2001-05-21) [umoeller]: fixed memory leak
  *@@changed V0.9.12 (2001-05-26) [umoeller]: fixed crash if !fAddFirst
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
@@ -363,4 +367,5 @@
  *
  *@@added V0.9.4 (2000-07-19) [umoeller]
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
@@ -434,4 +439,5 @@
  *
  *@@added V0.9.4 (2000-07-19) [umoeller]
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from dosh2.c to apps.c
  */
 
@@ -486,4 +492,5 @@
  *@@added V0.9.6 (2000-10-16) [umoeller]
  *@@changed V0.9.7 (2001-01-15) [umoeller]: now using XSTRING
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from winh.c to apps.c
  */
 
@@ -564,4 +571,5 @@
  *
  *@@added V0.9.9 (2001-03-07) [umoeller]
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from winh.c to apps.c
  */
 
@@ -735,6 +743,5 @@
  *      --  If PROGDETAILS specifies a Win-OS/2 session
  *          and PROGDETAILS.pszEnvironment is empty,
- *          this merges the current process environment
- *          with the default Win-OS/2 environment.
+ *          this uses the default Win-OS/2 environment.
  *          See appQueryDefaultWin31Environment.
  *
@@ -756,4 +763,5 @@
  *@@changed V0.9.9 (2001-01-27) [umoeller]: crashed if PROGDETAILS.pszExecutable was NULL
  *@@changed V0.9.12 (2001-05-26) [umoeller]: fixed PROG_DEFAULT
+ *@@changed V0.9.12 (2001-05-27) [umoeller]: moved from winh.c to apps.c
  */
 
@@ -918,6 +926,6 @@
             PSZ pszTemp = appQueryDefaultWin31Environment();
 
-            /* if (!appParseEnvironment(pszTemp,
-                                     &Env)) */
+            if (!appParseEnvironment(pszTemp,
+                                     &Env))
             {
                 // now override KBD_CTRL_BYPASS=CTRL_ESC
Index: trunk/src/helpers/semaphores.c
===================================================================
--- trunk/src/helpers/semaphores.c	(revision 77)
+++ trunk/src/helpers/semaphores.c	(revision 78)
@@ -169,5 +169,4 @@
  *      I have created, this returns an APIRET.
  *
- *@@added V0.9.12 (2001-05-27) [umoeller]
  */
 
@@ -187,5 +186,4 @@
  *@@ UnlockGlobal:
  *
- *@@added V0.9.12 (2001-05-27) [umoeller]
  */
 
@@ -258,10 +256,9 @@
  *          was set to NULLHANDLE.
  *
- *      --  ERROR_SEM_BUSY: couldn't delete one
- *          of the member semaphores because they
- *          were held by some other thread.
- */
-
-APIRET semDeleteRWMutex(PHRW phrw)
+ *      --  ERROR_SEM_BUSY: semaphore is currently
+ *          requested.
+ */
+
+APIRET semDeleteRWMutex(PHRW phrw)      // in/out: rwsem handle
 {
     APIRET  arc = NO_ERROR;
@@ -274,22 +271,29 @@
            )
         {
-            if (    (!(arc = DosCloseEventSem(pMutex->hevWriterDone)))
-                 && (!(arc = DosCloseEventSem(pMutex->hevReadersDone)))
+            if (    (pMutex->cReaders)
+                 || (pMutex->cWriters)
                )
+                arc = ERROR_SEM_BUSY;
+            else
             {
-                ULONG cItems = pMutex->cReaderThreads;
-                TREE **papNodes = treeBuildArray(pMutex->ReaderThreadsTree,
-                                                 &cItems);
-                if (papNodes)
+                if (    (!(arc = DosCloseEventSem(pMutex->hevWriterDone)))
+                     && (!(arc = DosCloseEventSem(pMutex->hevReadersDone)))
+                   )
                 {
-                    ULONG ul;
-                    for (ul = 0; ul < cItems; ul++)
-                        free(papNodes[ul]);
-
-                    free(papNodes);
+                    ULONG cItems = pMutex->cReaderThreads;
+                    TREE **papNodes = treeBuildArray(pMutex->ReaderThreadsTree,
+                                                     &cItems);
+                    if (papNodes)
+                    {
+                        ULONG ul;
+                        for (ul = 0; ul < cItems; ul++)
+                            free(papNodes[ul]);
+
+                        free(papNodes);
+                    }
+
+                    free(pMutex);
+                    *phrw = NULLHANDLE;
                 }
-
-                free(pMutex);
-                *phrw = NULLHANDLE;
             }
         }
