Copy WINEDEBUG from the Windows environment to allow passing a
modified value to a child process.

diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index fcfeb7c..572b3d3 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -1426,6 +1426,7 @@
     BOOL ret, success = FALSE;
     HANDLE process_info;
     WCHAR *env_end;
+    char *winedebug = NULL;
     RTL_USER_PROCESS_PARAMETERS *params;
     int startfd[2];
     int execfd[2];
@@ -1442,7 +1443,17 @@
         return FALSE;
     }
     env_end = params->Environment;
-    while (*env_end) env_end += strlenW(env_end) + 1;
+    while (*env_end)
+    {
+        static const WCHAR WINEDEBUG[] = {'W','I','N','E','D','E','B','U','G','=',0};
+        if (!winedebug && !strncmpW( env_end, WINEDEBUG, sizeof(WINEDEBUG)/sizeof(WCHAR) - 1 ))
+        {
+            DWORD len = WideCharToMultiByte( CP_UNIXCP, 0, env_end, -1, NULL, 0, NULL, NULL );
+            if ((winedebug = HeapAlloc( GetProcessHeap(), 0, len )))
+                WideCharToMultiByte( CP_UNIXCP, 0, env_end, -1, winedebug, len, NULL, NULL );
+        }
+        env_end += strlenW(env_end) + 1;
+    }
     env_end++;
 
     sprintf( preloader_reserve, "WINEPRELOADRESERVE=%lx-%lx%c",
@@ -1453,6 +1464,7 @@
     if (pipe( startfd ) == -1)
     {
         if (!env) RtlReleasePebLock();
+        HeapFree( GetProcessHeap(), 0, winedebug );
         SetLastError( ERROR_TOO_MANY_OPEN_FILES );
         RtlDestroyProcessParameters( params );
         return FALSE;
@@ -1460,6 +1472,7 @@
     if (pipe( execfd ) == -1)
     {
         if (!env) RtlReleasePebLock();
+        HeapFree( GetProcessHeap(), 0, winedebug );
         SetLastError( ERROR_TOO_MANY_OPEN_FILES );
         close( startfd[0] );
         close( startfd[1] );
@@ -1486,6 +1499,7 @@
         signal( SIGCHLD, SIG_DFL );
 
         putenv( preloader_reserve );
+        if (winedebug) putenv( winedebug );
         if (unixdir) chdir(unixdir);
 
         if (argv)
@@ -1505,6 +1519,7 @@
 
     close( startfd[0] );
     close( execfd[1] );
+    HeapFree( GetProcessHeap(), 0, winedebug );
     if (pid == -1)
     {
         if (!env) RtlReleasePebLock();