Index: branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h
===================================================================
--- branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h	(revision 3101)
+++ branches/libc-0.6/src/emx/include/InnoTekLIBC/backend.h	(revision 3102)
@@ -816,4 +816,12 @@
 int __libc_Back_signalTimer(int iWhich, const struct itimerval *pValue, struct itimerval *pOldValue);
 
+/**
+ * This is a hack to deal with potentially lost thread pokes.
+ * 
+ * For some reason or another we loose the async signal in some situations. It's 
+ * been observed happening after/when opening files (fopen), but it's not known
+ * whether this is really related or not.
+ */
+void __libc_Back_signalLostPoke(void);
 
 
Index: branches/libc-0.6/src/emx/src/lib/libc.def
===================================================================
--- branches/libc-0.6/src/emx/src/lib/libc.def	(revision 3101)
+++ branches/libc-0.6/src/emx/src/lib/libc.def	(revision 3102)
@@ -1958,3 +1958,5 @@
     "__std_nanf" @1956
     "__std_nanl" @1957
+    "___libc_Back_signalLostPoke" @1958
 
+
Index: branches/libc-0.6/src/emx/src/lib/process/fmutex.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/process/fmutex.c	(revision 3101)
+++ branches/libc-0.6/src/emx/src/lib/process/fmutex.c	(revision 3102)
@@ -17,4 +17,5 @@
 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_MUTEX
 #include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/thread.h>
 #include <InnoTekLIBC/backend.h>
 
@@ -200,4 +201,14 @@
     FS_SAVE_LOAD();
     DosEnterMustComplete(&ulNesting);
+    if (ulNesting == 1) /* This is a hack to catch lost poke signals. */
+    {
+        __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto();
+        if (pThrd && pThrd->fSigBeingPoked)
+        {
+            DosExitMustComplete(&ulNesting);
+            __libc_Back_signalLostPoke();
+            DosEnterMustComplete(&ulNesting);
+        }
+    }
     fs = __cxchg(&sem->fs, _FMS_OWNED_SIMPLE);
     if (fs == _FMS_AVAILABLE)
@@ -214,4 +225,5 @@
         if (rc)
         {
+            DosExitMustComplete(&ulNesting);
             LIBC_ASSERTM_FAILED("Failed to create event semaphore for fmutex '%s', rc=%d. flags=%#x\n", sem->pszDesc, rc, sem->flags);
             FS_RESTORE();
@@ -332,21 +344,24 @@
     LIBCLOG_ENTER("sem=%p{.pszDesc=%s}\n", (void *)sem, sem->pszDesc);
     ULONG ulNesting;
+
+    int rc = 0;
     __atomic_xchg(&sem->Owner, 0);
     signed char fs = __cxchg(&sem->fs, _FMS_AVAILABLE);
-    if (fs != _FMS_OWNED_HARD)
-    {
-        FS_VAR_SAVE_LOAD();
-        DosExitMustComplete(&ulNesting);
-        FS_RESTORE();
-        LIBCLOG_RETURN_UINT(0);
-    }
-    else
-    {
-        int rc = __fmutex_release_internal (sem);
-        FS_VAR_SAVE_LOAD();
-        DosExitMustComplete(&ulNesting);
-        FS_RESTORE();
-        LIBCLOG_RETURN_UINT(rc);
-    }
+    if (fs == _FMS_OWNED_HARD)
+        rc = __fmutex_release_internal (sem);
+
+    FS_VAR_SAVE_LOAD();
+    DosExitMustComplete(&ulNesting);
+    FS_RESTORE();
+
+    /* This is a hack to catch lost poke signals. */
+    if (!ulNesting)
+    {
+        __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto();
+        if (pThrd && pThrd->fSigBeingPoked)
+            __libc_Back_signalLostPoke();
+    }
+
+    LIBCLOG_RETURN_UINT(rc);
 }
 
Index: branches/libc-0.6/src/emx/src/lib/sys/signals.c
===================================================================
--- branches/libc-0.6/src/emx/src/lib/sys/signals.c	(revision 3101)
+++ branches/libc-0.6/src/emx/src/lib/sys/signals.c	(revision 3102)
@@ -2478,8 +2478,13 @@
     if (!pThrdPoke->fSigBeingPoked)
     {
+        DosSuspendThread(pThrdPoke->tid);
         __atomic_xchg(&pThrdPoke->fSigBeingPoked, 1);
         int rc = DosKillThread(pThrdPoke->tid);
+        DosResumeThread(pThrdPoke->tid);
         if (rc)
+        {
+            __atomic_xchg(&pThrdPoke->fSigBeingPoked, 0);
             LIBC_ASSERTM_FAILED("DosKillThread(%d) -> rc=%d\n", pThrdPoke->tid, rc);
+        }
     }
 
@@ -2532,4 +2537,50 @@
 
     return -EINVAL;
+}
+
+
+/**
+ * This is a hack to deal with potentially lost thread pokes.
+ * 
+ * For some reason or another we loose the async signal in some situations. It's 
+ * been observed happening after/when opening files (fopen), but it's not known
+ * whether this is really related or not.
+ */
+void        __libc_Back_signalLostPoke(void)
+{
+    LIBCLOG_ENTER("\n");
+    __LIBC_PTHREAD pThrd = __libc_threadCurrentNoAuto();
+    if (pThrd && pThrd->fSigBeingPoked)
+    {
+        ULONG ulSigLastTS = pThrd->ulSigLastTS;
+        DosSleep(0);
+        if (    pThrd->fSigBeingPoked
+            &&  pThrd->ulSigLastTS == ulSigLastTS)
+        {
+            DosSleep(0);
+            if (    pThrd->fSigBeingPoked
+                &&  pThrd->ulSigLastTS == ulSigLastTS)
+            {
+
+                int rc = __libc_back_signalSemRequest();
+                if (!rc)
+                {
+                    if (    pThrd->fSigBeingPoked
+                        &&  pThrd->ulSigLastTS == ulSigLastTS)
+                    {
+                        /*
+                         * Clear the indicator and deliver signals (releaseing the semaphore).
+                         */
+                        __atomic_xchg(&pThrd->fSigBeingPoked, 0);
+                        signalDeliver(pThrd, 0, NULL);
+                        LIBCLOG_RETURN_VOID();
+                        return;
+                    }
+                    __libc_back_signalSemRelease();
+                }
+            }
+        }
+    }
+    LIBCLOG_RETURN_VOID();
 }
 
