Index: trunk/src/kernel32/HandleManager.cpp
===================================================================
--- trunk/src/kernel32/HandleManager.cpp	(revision 9647)
+++ trunk/src/kernel32/HandleManager.cpp	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: HandleManager.cpp,v 1.91 2002-09-14 13:49:39 sandervl Exp $ */
+/* $Id: HandleManager.cpp,v 1.92 2003-01-10 12:57:11 sandervl Exp $ */
 
 /*
@@ -268,4 +268,5 @@
         TabWin32Handles[ulLoop].hmHandleData.hWin32Handle   = (HANDLE)ulLoop;
         TabWin32Handles[ulLoop].hmHandleData.lpDeviceData   = NULL;
+        TabWin32Handles[ulLoop].hmHandleData.dwHandleInformation = 0;
         handleMutex.leave();
         return (ulLoop);                    /* OK, then return it to the caller */
@@ -1083,4 +1084,5 @@
     HMHandleTemp.hWin32Handle  = iIndexNew;
     HMHandleTemp.lpDeviceData  = pDevData;
+    HMHandleTemp.dwHandleInformation = 0;
   }
 
@@ -1286,5 +1288,90 @@
 }
 
-
+/*****************************************************************************
+ * Name      : DWORD HMGetHandleInformation
+ * Purpose   : The GetHandleInformation function obtains information about certain
+ *             properties of an object handle. The information is obtained as a set of bit flags.
+ * Parameters: HANDLE  hObject
+ *             LPDWORD lpdwFlags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMGetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
+{
+  int       iIndex;                           /* index into the handle table */
+  BOOL      fResult;       /* result from the device handler's CloseHandle() */
+  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
+
+                                                          /* validate handle */
+  iIndex = _HMHandleQuery(hObject);                         /* get the index */
+  if (-1 == iIndex)                                               /* error ? */
+  {
+      SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
+      return (FALSE);                                        /* signal failure */
+  }
+
+  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+
+  //Handle information is stored in the handle structure; return it here
+  if(lpdwFlags) {
+      *lpdwFlags = pHMHandle->hmHandleData.dwHandleInformation;
+  }
+
+  SetLastError(ERROR_SUCCESS);
+  return TRUE;                                   /* deliver return code */
+}
+
+/*****************************************************************************
+ * Name      : BOOL HMSetHandleInformation
+ * Purpose   : The SetHandleInformation function sets certain properties of an
+ *             object handle. The information is specified as a set of bit flags.
+ * Parameters: HANDLE hObject  handle to an object
+ *             DWORD  dwMask   specifies flags to change
+ *             DWORD  dwFlags  specifies new values for flags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL   HMSetHandleInformation       (HANDLE hObject, 
+                                     DWORD  dwMask,
+                                     DWORD  dwFlags)
+{
+  int       iIndex;                           /* index into the handle table */
+  BOOL      fResult;       /* result from the device handler's CloseHandle() */
+  PHMHANDLE pHMHandle;       /* pointer to the handle structure in the table */
+
+                                                          /* validate handle */
+  iIndex = _HMHandleQuery(hObject);                         /* get the index */
+  if (-1 == iIndex)                                               /* error ? */
+  {
+    SetLastError(ERROR_INVALID_HANDLE);       /* set win32 error information */
+    return (FALSE);                                        /* signal failure */
+  }
+
+  pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+  //SvL: Check if pDeviceHandler is set
+  if (pHMHandle->pDeviceHandler)
+  {
+    fResult = pHMHandle->pDeviceHandler->SetHandleInformation(&pHMHandle->hmHandleData,
+                                                              dwMask, dwFlags);
+  }
+  else
+  {
+    dprintf(("HMSetHandleInformation(%08xh): pDeviceHandler not set", hObject));
+    fResult = TRUE;
+  }
+
+  if(fResult == TRUE) {
+      SetLastError(ERROR_SUCCESS);
+  }
+  return (fResult);                                   /* deliver return code */
+}
 
 /*****************************************************************************
@@ -1324,4 +1411,11 @@
 
   pHMHandle = &TabWin32Handles[iIndex];               /* call device handler */
+
+  if(pHMHandle->hmHandleData.dwHandleInformation & HANDLE_FLAG_PROTECT_FROM_CLOSE) {
+      dprintf(("Handle not close because of HANDLE_FLAG_PROTECT_FROM_CLOSE"));
+      SetLastError(ERROR_SUCCESS);
+      return TRUE;
+  }
+
   //SvL: Check if pDeviceHandler is set
   if (pHMHandle->pDeviceHandler)
Index: trunk/src/kernel32/KERNEL32.CPP
===================================================================
--- trunk/src/kernel32/KERNEL32.CPP	(revision 9647)
+++ trunk/src/kernel32/KERNEL32.CPP	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: KERNEL32.CPP,v 1.72 2002-02-15 20:15:54 sandervl Exp $ */
+/* $Id: KERNEL32.CPP,v 1.73 2003-01-10 12:57:12 sandervl Exp $ */
 
 /*
@@ -53,4 +53,45 @@
 
 
+/*****************************************************************************
+ * Name      : DWORD GetHandleInformation
+ * Purpose   : The GetHandleInformation function obtains information about certain
+ *             properties of an object handle. The information is obtained as a set of bit flags.
+ * Parameters: HANDLE  hObject
+ *             LPDWORD lpdwFlags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL WIN32API GetHandleInformation(HANDLE  hObject,
+                                   LPDWORD lpdwFlags)
+{
+   return HMGetHandleInformation(hObject, lpdwFlags);
+}
+
+/*****************************************************************************
+ * Name      : BOOL SetHandleInformation
+ * Purpose   : The SetHandleInformation function sets certain properties of an
+ *             object handle. The information is specified as a set of bit flags.
+ * Parameters: HANDLE hObject  handle to an object
+ *             DWORD  dwMask   specifies flags to change
+ *             DWORD  dwFlags  specifies new values for flags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+
+BOOL WIN32API SetHandleInformation(HANDLE hObject,
+                                   DWORD  dwMask,
+                                   DWORD  dwFlags)
+{
+   return HMSetHandleInformation(hObject, dwMask, dwFlags);
+}
 /*****************************************************************************
  * Name      : BOOL WIN32API CloseHandle
Index: trunk/src/kernel32/hmdevice.cpp
===================================================================
--- trunk/src/kernel32/hmdevice.cpp	(revision 9647)
+++ trunk/src/kernel32/hmdevice.cpp	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.cpp,v 1.32 2002-05-10 14:55:11 sandervl Exp $ */
+/* $Id: hmdevice.cpp,v 1.33 2003-01-10 12:57:12 sandervl Exp $ */
 
 /*
@@ -200,4 +200,30 @@
 {
   dprintf(("KERNEL32:HandleManager::CloseHandle %s(%08x) - stub?\n",
+           lpHMDeviceName,
+           pHMHandleData));
+
+  SetLastError(ERROR_INVALID_FUNCTION);
+  return FALSE;
+}
+
+/*****************************************************************************
+ * Name      : BOOL HMSetHandleInformation
+ * Purpose   : The SetHandleInformation function sets certain properties of an
+ *             object handle. The information is specified as a set of bit flags.
+ * Parameters: HANDLE hObject  handle to an object
+ *             DWORD  dwMask   specifies flags to change
+ *             DWORD  dwFlags  specifies new values for flags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMDeviceHandler::SetHandleInformation(PHMHANDLEDATA pHMHandleData,
+                                           DWORD  dwMask,
+                                           DWORD  dwFlags)
+{
+  dprintf(("KERNEL32:HandleManager::SetHandleInformation %s(%08x) - stub?\n",
            lpHMDeviceName,
            pHMHandleData));
Index: trunk/src/kernel32/hmdevice.h
===================================================================
--- trunk/src/kernel32/hmdevice.h	(revision 9647)
+++ trunk/src/kernel32/hmdevice.h	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: hmdevice.h,v 1.32 2001-12-05 14:16:00 sandervl Exp $ */
+/* $Id: hmdevice.h,v 1.33 2003-01-10 12:57:13 sandervl Exp $ */
 
 /*
@@ -55,4 +55,5 @@
   DWORD           dwUserData;
   DWORD           dwInternalType;
+  DWORD           dwHandleInformation;               /* Set by SetHandleInformation */
 
   LPVOID          lpHandlerData;    /* for private use of the device handler */
@@ -114,4 +115,8 @@
   /* this is a handler method for calls to CloseHandle() */
   virtual BOOL   CloseHandle(PHMHANDLEDATA pHMHandleData);
+
+  virtual BOOL   SetHandleInformation(PHMHANDLEDATA pHMHandleData,
+                                      DWORD  dwMask,
+                                      DWORD  dwFlags);
 
   /* this is a handler method for calls to ReadFile/Ex */
Index: trunk/src/kernel32/hmfile.cpp
===================================================================
--- trunk/src/kernel32/hmfile.cpp	(revision 9647)
+++ trunk/src/kernel32/hmfile.cpp	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: hmfile.cpp,v 1.37 2002-12-19 12:55:27 sandervl Exp $ */
+/* $Id: hmfile.cpp,v 1.38 2003-01-10 12:57:13 sandervl Exp $ */
 
 /*
@@ -351,4 +351,7 @@
         {
             memcpy(pHMHandleData, &duphdata, sizeof(duphdata));
+
+            if(fInherit) SetHandleInformation(pHMHandleData, ~HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+
             SetLastError(ERROR_SUCCESS);
             return TRUE;
@@ -368,11 +371,12 @@
     if (rc)
     {
-      dprintf(("ERROR: DulicateHandle: OSLibDosDupHandle(%s) failed = %u\n",
-               rc,
-               srcfileinfo->lpszFileName));
+      dprintf(("ERROR: DuplicateHandle: OSLibDosDupHandle(%s) failed = %u",
+               srcfileinfo->lpszFileName, rc));
       SetLastError(rc);
       return FALSE;   // ERROR
     }
     else {
+      if(fInherit) SetHandleInformation(pHMHandleData, ~HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+
       SetLastError(ERROR_SUCCESS);
       pHMHandleData->hHMHandle = *desthandle;
@@ -386,4 +390,41 @@
     return FALSE;
   }
+}
+
+/*****************************************************************************
+ * Name      : BOOL HMDeviceFileClass::SetHandleInformation
+ * Purpose   : The SetHandleInformation function sets certain properties of an
+ *             object handle. The information is specified as a set of bit flags.
+ * Parameters: HANDLE hObject  handle to an object
+ *             DWORD  dwMask   specifies flags to change
+ *             DWORD  dwFlags  specifies new values for flags
+ * Variables :
+ * Result    : TRUE / FALSE
+ * Remark    :
+ * Status    : 
+ *
+ * Author    : SvL
+ *****************************************************************************/
+BOOL HMDeviceFileClass::SetHandleInformation(PHMHANDLEDATA pHMHandleData,
+                                             DWORD  dwMask,
+                                             DWORD  dwFlags)
+{
+    DWORD rc;
+
+    pHMHandleData->dwHandleInformation &= ~dwMask;
+    pHMHandleData->dwHandleInformation |= (dwFlags & dwMask);
+
+    rc = OSLibDosSetFHState(pHMHandleData->hHMHandle,
+                            pHMHandleData->dwHandleInformation);
+    if (rc)
+    {
+        dprintf(("ERROR: SetHandleInformation: OSLibDosSetFHState failed with %d", rc));
+
+        SetLastError(rc);
+        return FALSE;
+    }
+
+    SetLastError(ERROR_SUCCESS);
+    return TRUE;
 }
 
Index: trunk/src/kernel32/hmfile.h
===================================================================
--- trunk/src/kernel32/hmfile.h	(revision 9647)
+++ trunk/src/kernel32/hmfile.h	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: hmfile.h,v 1.7 2001-12-05 14:16:01 sandervl Exp $ */
+/* $Id: hmfile.h,v 1.8 2003-01-10 12:57:13 sandervl Exp $ */
 
 /*
@@ -64,4 +64,8 @@
                                DWORD   fdwOptions,
                                DWORD   fdwOdinOptions);
+
+  virtual BOOL   SetHandleInformation(PHMHANDLEDATA pHMHandleData,
+                                      DWORD  dwMask,
+                                      DWORD  dwFlags);
 
                       /* this is a handler method for calls to CloseHandle() */
Index: trunk/src/kernel32/oslibdos.cpp
===================================================================
--- trunk/src/kernel32/oslibdos.cpp	(revision 9647)
+++ trunk/src/kernel32/oslibdos.cpp	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.cpp,v 1.110 2002-12-19 12:55:27 sandervl Exp $ */
+/* $Id: oslibdos.cpp,v 1.111 2003-01-10 12:57:13 sandervl Exp $ */
 /*
  * Wrappers for OS/2 Dos* API
@@ -430,5 +430,5 @@
  HFILE  hFile;
  ULONG  ulAction;
- DWORD  os2flags = OPEN_FLAGS_NOINHERIT;
+ DWORD  os2flags = OPEN_FLAGS_NOINHERIT; //default is not inherited by child processes
  char lOemFileName[260];
 
@@ -843,5 +843,5 @@
    ULONG   fileAttr = FILE_NORMAL;
    ULONG   openFlag = 0;
-   ULONG   openMode = 0;
+   ULONG   openMode = OPEN_FLAGS_NOINHERIT; //default is not inherited by child processes
    APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;;
 
@@ -1020,5 +1020,5 @@
    ULONG   fileAttr = FILE_NORMAL;
    ULONG   openFlag = 0;
-   ULONG   openMode = 0;
+   ULONG   openMode = OPEN_FLAGS_NOINHERIT; //default is not inherited by child processes
    APIRET  rc = ERROR_NOT_ENOUGH_MEMORY;
    HFILE   hFile;
@@ -1471,4 +1471,26 @@
 }
 //******************************************************************************
+//******************************************************************************
+DWORD OSLibDosSetFHState(DWORD hFile, DWORD dwFlags)
+{
+   DWORD  ulMode;
+   APIRET rc;
+   
+   rc = DosQueryFHState(hFile, &ulMode);
+   if(rc != NO_ERROR) return error2WinError(rc);
+
+   //turn off non-participating bits
+   ulMode &= 0x7F88;
+
+   if(dwFlags & HANDLE_FLAG_INHERIT_W) {
+       ulMode &= ~OPEN_FLAGS_NOINHERIT;
+   }
+   else 
+       ulMode |= OPEN_FLAGS_NOINHERIT;
+
+   rc = DosSetFHState(hFile, ulMode);
+   return error2WinError(rc);
+}
+//******************************************************************************
 //Returns time spent in kernel & user mode in milliseconds
 //******************************************************************************
@@ -1515,5 +1537,5 @@
                                DWORD   nDefaultTimeOut,
                                LPSECURITY_ATTRIBUTES lpSecurityAttributes)
-{  DWORD dwOS2Mode     = 0;
+{  DWORD dwOS2Mode     = NP_NOINHERIT; //default is not inherited by child processes
    DWORD dwOS2PipeMode = 0;
    LPSTR lpOS2Name;
@@ -1574,5 +1596,5 @@
   rc = DosOpen(lpOS2Name, &hPipe, &ulAction, 0, FILE_NORMAL, FILE_OPEN,
                ((dwOpenMode & PIPE_ACCESS_INBOUND_W) ? OPEN_ACCESS_READWRITE : OPEN_ACCESS_READONLY) |
-               OPEN_SHARE_DENYNONE, NULL);
+               OPEN_SHARE_DENYNONE | OPEN_FLAGS_NOINHERIT, NULL);
 
   if(rc == NO_ERROR) {
@@ -1646,5 +1668,5 @@
   ULONG rc, ulAction;
   ULONG openFlag = 0;
-  ULONG openMode = 0;
+  ULONG openMode = OPEN_FLAGS_NOINHERIT; //default is not inherited by child processes
 
 
@@ -2609,5 +2631,5 @@
         if (DosOpen("\\DEV\\CD-ROM2$", &hCDRom2, &ulAction, 0,
                     FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
-                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL)
+                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY | OPEN_FLAGS_NOINHERIT, NULL)
             == NO_ERROR)
         {
@@ -2864,5 +2886,5 @@
         if (DosOpen("\\DEV\\CD-ROM2$", &hCDRom2, &ulAction, 0,
                     FILE_NORMAL, OPEN_ACTION_OPEN_IF_EXISTS,
-                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL)
+                    OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY | OPEN_FLAGS_NOINHERIT, NULL)
             == NO_ERROR)
         {
Index: trunk/src/kernel32/oslibdos.h
===================================================================
--- trunk/src/kernel32/oslibdos.h	(revision 9647)
+++ trunk/src/kernel32/oslibdos.h	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: oslibdos.h,v 1.50 2003-01-05 12:31:24 sandervl Exp $ */
+/* $Id: oslibdos.h,v 1.51 2003-01-10 12:57:14 sandervl Exp $ */
 
 /*
@@ -113,4 +113,6 @@
 
 DWORD OSLibDosDupHandle(DWORD hFile, DWORD *hNew);
+DWORD OSLibDosSetFHState(DWORD hFile, DWORD dwFlags);
+
 DWORD OSLibDosSetFilePtr2(DWORD hFile, DWORD offset, DWORD method);
 
Index: trunk/src/kernel32/stubs.cpp
===================================================================
--- trunk/src/kernel32/stubs.cpp	(revision 9647)
+++ trunk/src/kernel32/stubs.cpp	(revision 9653)
@@ -1,3 +1,3 @@
-/* $Id: stubs.cpp,v 1.36 2001-12-06 10:14:45 sandervl Exp $
+/* $Id: stubs.cpp,v 1.37 2003-01-10 12:57:14 sandervl Exp $
  *
  * Win32 KERNEL32 Subsystem for OS/2
@@ -870,30 +870,4 @@
 
 
-/*****************************************************************************
- * Name      : DWORD GetHandleInformation
- * Purpose   : The GetHandleInformation function obtains information about certain
- *             properties of an object handle. The information is obtained as a set of bit flags.
- * Parameters: HANDLE  hObject
- *             LPDWORD lpdwFlags
- * Variables :
- * Result    : TRUE / FALSE
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
- *****************************************************************************/
-
-BOOL WIN32API GetHandleInformation(HANDLE  hObject,
-                                      LPDWORD lpdwFlags)
-{
-  dprintf(("KERNEL32: GetHandleInformation (%08xh, %08xh) not implemented\n",
-           hObject,
-           lpdwFlags));
-
-  return (FALSE);
-}
-
-
-
 
 /*****************************************************************************
@@ -1356,32 +1330,4 @@
 }
 
-
-/*****************************************************************************
- * Name      : BOOL SetHandleInformation
- * Purpose   : The SetHandleInformation function sets certain properties of an
- *             object handle. The information is specified as a set of bit flags.
- * Parameters: HANDLE hObject  handle to an object
- *             DWORD  dwMask   specifies flags to change
- *             DWORD  dwFlags  specifies new values for flags
- * Variables :
- * Result    : TRUE / FALSE
- * Remark    :
- * Status    : UNTESTED STUB
- *
- * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
- *****************************************************************************/
-
-BOOL WIN32API SetHandleInformation(HANDLE hObject,
-                                      DWORD  dwMask,
-                                      DWORD  dwFlags)
-{
-  dprintf(("KERNEL32: SetHandleInformation(%08xh,%08xh,%08xh) not implemented.\n",
-           hObject,
-           dwMask,
-           dwFlags));
-
-  return (FALSE);
-}
-
 /*****************************************************************************
  * Name      : BOOL SetSystemPowerState
