Index: trunk/src/kernel32/HandleManager.cpp
===================================================================
--- trunk/src/kernel32/HandleManager.cpp	(revision 9658)
+++ trunk/src/kernel32/HandleManager.cpp	(revision 9660)
@@ -1,3 +1,3 @@
-/* $Id: HandleManager.cpp,v 1.92 2003-01-10 12:57:11 sandervl Exp $ */
+/* $Id: HandleManager.cpp,v 1.93 2003-01-10 15:19:53 sandervl Exp $ */
 
 /*
@@ -1121,10 +1121,15 @@
   else
   {
-    SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?
-
-             /* copy data fields that might have been modified by CreateFile */
+    /* copy data fields that might have been modified by CreateFile */
     memcpy(&TabWin32Handles[iIndexNew].hmHandleData,
            &HMHandleTemp,
            sizeof(HMHANDLEDATA));
+
+    if(lpSecurityAttributes && lpSecurityAttributes->bInheritHandle) {
+        dprintf(("Set inheritance for child processes"));
+        HMSetHandleInformation(iIndexNew, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+    }
+
+    SetLastError(ERROR_SUCCESS); //@@@PH 1999/10/27 rc5desg requires this?
   }
 
@@ -4513,4 +4518,10 @@
   }
 
+  dprintf(("Named pipe %x", iIndexNew));
+  if(lpSecurityAttributes && lpSecurityAttributes->bInheritHandle) {
+      dprintf(("Set inheritance for child processes"));
+      HMSetHandleInformation(iIndexNew, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+  }
+
   return iIndexNew;
 }
@@ -4760,7 +4771,7 @@
  *****************************************************************************/
 BOOL HMCreatePipe(PHANDLE phRead,
-                PHANDLE phWrite,
-                LPSECURITY_ATTRIBUTES lpsa,
-                DWORD                 cbPipe)
+                  PHANDLE phWrite,
+                  LPSECURITY_ATTRIBUTES lpsa,
+                  DWORD                 cbPipe)
 {
   int             iIndex;                     /* index into the handle table */
@@ -4834,4 +4845,11 @@
   }
 
+  dprintf(("Read pipe %x, Write pipe %x", iIndexNewRead, iIndexNewWrite));
+  if(lpsa && lpsa->bInheritHandle) {
+      dprintf(("Set inheritance for child processes"));
+      HMSetHandleInformation(iIndexNewRead, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+      HMSetHandleInformation(iIndexNewWrite, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+  }
+
   *phRead  = iIndexNewRead;
   *phWrite = iIndexNewWrite;
Index: trunk/src/kernel32/hmnpipe.cpp
===================================================================
--- trunk/src/kernel32/hmnpipe.cpp	(revision 9658)
+++ trunk/src/kernel32/hmnpipe.cpp	(revision 9660)
@@ -1,3 +1,3 @@
-/* $Id: hmnpipe.cpp,v 1.9 2002-02-15 20:15:55 sandervl Exp $ */
+/* $Id: hmnpipe.cpp,v 1.10 2003-01-10 15:19:53 sandervl Exp $ */
 /*
  * Project Odin Software License can be found in LICENSE.TXT
@@ -201,12 +201,14 @@
                          lpsa,
                          cbPipe))
-    return TRUE;
+  {
+     return TRUE;
+  }
   else
-    return(FALSE);
+     return FALSE;
 }
 //******************************************************************************
 //******************************************************************************
 BOOL HMDeviceNamedPipeClass::ConnectNamedPipe( PHMHANDLEDATA pHMHandleData, 
-                                          LPOVERLAPPED lpOverlapped)
+                                               LPOVERLAPPED lpOverlapped)
 {
   dprintfl(("KERNEL32: HMDeviceNamedPipeClass::ConnectNamedPipe %s(%08x) [%08x]\n",
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 9658)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 9660)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.111 2003-01-10 12:57:13 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.112 2003-01-10 15:19:54 sandervl Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -1840,22 +1840,44 @@
 //******************************************************************************
 BOOL OSLibDosPeekNamedPipe(DWORD   hPipe,
-                        LPVOID  lpvBuffer,
-                        DWORD   cbBuffer,
-                        LPDWORD lpcbRead,
-                        LPDWORD lpcbAvail,
-                        LPDWORD lpcbMessage)
+                           LPVOID  lpvBuffer,
+                           DWORD   cbBuffer,
+                           LPDWORD lpcbRead,
+                           LPDWORD lpcbAvail,
+                           LPDWORD lpcbMessage)
 {
   DWORD     rc;
   AVAILDATA availData ={0};
-  ULONG     ulDummy;
-
-  rc=DosPeekNPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,&availData,&ulDummy);
+  ULONG     ulState, ulRead, ulMessage;
+  char      buffer;
+
+  if(lpcbRead == NULL) {
+      lpcbRead = &ulRead;
+  }
+  if(lpcbMessage == NULL) {
+      lpcbMessage = &ulMessage;
+  }
+  if(lpvBuffer == NULL) {
+      lpvBuffer = &buffer;
+      cbBuffer = 0;
+  }
+
+  rc = DosPeekNPipe(hPipe,lpvBuffer,cbBuffer,lpcbRead,&availData,&ulState);
 
   dprintf(("DosPeekNPipe returned rc=%d",rc));
 
-  if (!rc)
-  {
-    *lpcbAvail   = availData.cbpipe;
-    *lpcbMessage = availData.cbmessage;
+  //OS/2 doesn't support DosPeekNPipe for unnamed pipes; win32 does
+  if (rc == 1) {
+     dprintf(("WARNING: Pretend broken pipe for PeekNamedPipe with unnamed pipe handle"));
+     SetLastError(ERROR_BROKEN_PIPE_W);
+     return FALSE;
+  }
+  if (rc == NO_ERROR)
+  {
+    if(lpcbAvail) {
+        *lpcbAvail   = availData.cbpipe;
+    }
+    if(lpcbMessage) {
+        *lpcbMessage = availData.cbmessage;
+    }
     SetLastError(ERROR_SUCCESS_W);
     return (TRUE);
Index: trunk/src/kernel32/wprocess.cpp
===================================================================
--- trunk/src/kernel32/wprocess.cpp	(revision 9658)
+++ trunk/src/kernel32/wprocess.cpp	(revision 9660)
@@ -1,3 +1,3 @@
-/* $Id: wprocess.cpp,v 1.170 2003-01-06 14:43:51 sandervl Exp $ */
+/* $Id: wprocess.cpp,v 1.171 2003-01-10 15:19:54 sandervl Exp $ */
 
 /*
@@ -1808,4 +1808,5 @@
                             LPPROCESS_INFORMATION lpProcessInfo )
 {
+ STARTUPINFOA startinfo;
  TEB *pThreadDB = (TEB*)GetThreadTEB();
  char *cmdline = NULL;
@@ -1818,21 +1819,39 @@
 #ifdef DEBUG
     if(lpStartupInfo) {
-    dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
-    dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
-    dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
-    dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
-    dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
-    dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
-    dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
-    dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
-    dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
-    dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
-    dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
-    dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
-    dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
-    dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
-    dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
+        dprintf(("lpStartupInfo->lpReserved %x", lpStartupInfo->lpReserved));
+        dprintf(("lpStartupInfo->lpDesktop %x", lpStartupInfo->lpDesktop));
+        dprintf(("lpStartupInfo->lpTitle %s", lpStartupInfo->lpTitle));
+        dprintf(("lpStartupInfo->dwX %x", lpStartupInfo->dwX));
+        dprintf(("lpStartupInfo->dwY %x", lpStartupInfo->dwY));
+        dprintf(("lpStartupInfo->dwXSize %x", lpStartupInfo->dwXSize));
+        dprintf(("lpStartupInfo->dwYSize %x", lpStartupInfo->dwYSize));
+        dprintf(("lpStartupInfo->dwXCountChars %x", lpStartupInfo->dwXCountChars));
+        dprintf(("lpStartupInfo->dwYCountChars %x", lpStartupInfo->dwYCountChars));
+        dprintf(("lpStartupInfo->dwFillAttribute %x", lpStartupInfo->dwFillAttribute));
+        dprintf(("lpStartupInfo->dwFlags %x", lpStartupInfo->dwFlags));
+        dprintf(("lpStartupInfo->wShowWindow %x", lpStartupInfo->wShowWindow));
+        dprintf(("lpStartupInfo->hStdInput %x", lpStartupInfo->hStdInput));
+        dprintf(("lpStartupInfo->hStdOutput %x", lpStartupInfo->hStdOutput));
+        dprintf(("lpStartupInfo->hStdError %x", lpStartupInfo->hStdError));
     }
 #endif
+
+    if(bInheritHandles && lpStartupInfo->dwFlags & STARTF_USESTDHANDLES) 
+    {
+        //Translate standard handles if the child needs to inherit them
+        int retcode = 0;
+
+        memcpy(&startinfo, lpStartupInfo, sizeof(startinfo));
+        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdInput, &startinfo.hStdInput);
+        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdOutput, &startinfo.hStdOutput);
+        retcode |= HMHandleTranslateToOS2(lpStartupInfo->hStdError, &startinfo.hStdError);
+
+        if(retcode) {  
+            SetLastError(ERROR_INVALID_HANDLE);
+            return FALSE;
+        }
+
+        lpStartupInfo = &startinfo;
+    }
 
     // open32 does not support DEBUG_ONLY_THIS_PROCESS
