Fix keyboard input for DOS programs, which is totally broken on 2.6 kernels. The reason is the behavior of kill() which causes signals to end up in the wrong thread.

Peter Dons Tychsen donpedro at tdcadsl.dk
Sun Nov 9 07:07:44 CST 2008


This is an up-to-date revamp of a patch by Markus Amsler.
---
 dlls/winedos/dosvm.c  |   18 ++++++++++++++++--
 dlls/winedos/module.c |    2 +-
 server/protocol.def   |    9 +++++++++
 server/thread.c       |   12 ++++++++++++
 4 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c
index c139023..832968e 100644
--- a/dlls/winedos/dosvm.c
+++ b/dlls/winedos/dosvm.c
@@ -51,6 +51,7 @@
 
 #include "dosexe.h"
 #include "dosvm.h"
+#include "wine/server.h"
 #include "wine/debug.h"
 #include "excpt.h"
 
@@ -60,6 +61,8 @@ WINE_DECLARE_DEBUG_CHANNEL(module);
 WINE_DECLARE_DEBUG_CHANNEL(relay);
 #endif
 
+extern HANDLE dosvm_thread, loop_thread;
+
 WORD DOSVM_psp = 0;
 WORD DOSVM_retval = 0;
 
@@ -280,11 +283,22 @@ void WINAPI DOSVM_QueueEvent( INT irq, INT priority, DOSRELAY relay, LPVOID data
     else pending_event = event;
 
     if (!old_pending && DOSVM_HasPendingEvents()) {
+      BOOL success;
       TRACE("new event queued, signalling (time=%d)\n", GetTickCount());
       
       /* Alert VM86 thread about the new event. */
-      kill(dosvm_pid,SIGUSR2);
-
+      SERVER_START_REQ( send_thread_signal )
+      {
+        req->handle = dosvm_thread;
+        req->signal = SIGUSR2;
+        wine_server_call( req );
+        success = reply->success;
+      }
+      SERVER_END_REQ;
+        
+      if (!success)
+        ERR ("Couldn't alert vm86 thread!\n");
+ 
       /* Wake up DOSVM_Wait so that it can serve pending events. */
       SetEvent(event_notifier);
     } else {
diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c
index 0aa389f..404963b 100644
--- a/dlls/winedos/module.c
+++ b/dlls/winedos/module.c
@@ -105,9 +105,9 @@ typedef struct {
 /* global variables */
 
 pid_t dosvm_pid;
+HANDLE dosvm_thread, loop_thread;
 
 static WORD init_cs,init_ip,init_ss,init_sp;
-static HANDLE dosvm_thread, loop_thread;
 static DWORD dosvm_tid, loop_tid;
 
 static void MZ_Launch( LPCSTR cmdtail, int length );
diff --git a/server/protocol.def b/server/protocol.def
index bb7b47c..5a2b36d 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -3107,3 +3107,12 @@ enum message_type
     unsigned int   alpha;         /* alpha (0..255) */
     unsigned int   flags;         /* LWA_* flags */
 @END
+
+
+/* Send a Unix signal to a specific thread */
+ at REQ(send_thread_signal)
+    obj_handle_t handle;       /* thread handle */
+    int          signal;       /* the unix signal */
+ at REPLY
+    int          success;      /* wether signaling succeeded */
+ at END
diff --git a/server/thread.c b/server/thread.c
index 0c496db..9a2d88b 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -1428,3 +1428,15 @@ DECL_HANDLER(get_selector_entry)
         release_object( thread );
     }
 }
+
+/* send a Unix signal to a specific thread */
+DECL_HANDLER(send_thread_signal)
+{
+    struct thread *thread;
+
+    if ((thread = get_thread_from_handle( req->handle, THREAD_SUSPEND_RESUME )))
+    {
+        reply->success = send_thread_signal( thread, req->signal );
+        release_object( thread );
+    }
+}
-- 
1.5.4.3


--=-6jmgr1iNeg8szbTuvKUf--




More information about the wine-patches mailing list