Set the NOINHERIT bit in all channels, so that the handles associated
authorChris Hanson <org/chris-hanson/cph>
Fri, 6 Jan 1995 00:02:36 +0000 (00:02 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 6 Jan 1995 00:02:36 +0000 (00:02 +0000)
with those channels will not be inherited by subprocesses.  The
subprocess support will disable the bit in those channels that want to
be inherited.

v7/src/microcode/os2io.c

index 25ab024be731ac73a8c8fefe7be78ee55275d87c..946623ea42603ccb6c503f66052fef1020a3cbba 100644 (file)
@@ -1,8 +1,8 @@
 /* -*-C-*-
 
-$Id: os2io.c,v 1.2 1994/12/19 22:31:30 cph Exp $
+$Id: os2io.c,v 1.3 1995/01/06 00:02:36 cph Exp $
 
-Copyright (c) 1994 Massachusetts Institute of Technology
+Copyright (c) 1994-95 Massachusetts Institute of Technology
 
 This material was developed by the Scheme project at the Massachusetts
 Institute of Technology, Department of Electrical Engineering and
@@ -39,6 +39,7 @@ extern void OS2_initialize_console_channel (Tchannel);
 extern void OS2_initialize_pipe_channel (Tchannel);
 \f
 static enum channel_type handle_channel_type (LHANDLE);
+static void handle_noinherit (LHANDLE);
 
 size_t OS_channel_table_size;
 struct channel * OS2_channel_table;
@@ -97,6 +98,7 @@ OS2_make_channel (LHANDLE handle, unsigned int mode)
       channel += 1;
     }
   type = (handle_channel_type (handle));
+  handle_noinherit (handle);
   (CHANNEL_HANDLE (channel)) = handle;
   (CHANNEL_TYPE (channel)) = type;
   (CHANNEL_OPEN (channel)) = 1;
@@ -158,6 +160,20 @@ handle_channel_type (LHANDLE handle)
   OS2_error_anonymous ();
   return (channel_type_unknown);
 }
+
+static void
+handle_noinherit (LHANDLE handle)
+{
+  ULONG state;
+  STD_API_CALL (dos_query_fh_state, (handle, (& state)));
+  /* Magic mask 0xFF88 zeroes out high bits and two fields
+     required to be zero by the spec.  When testing, the high
+     bits were not zero, and this caused the system call to
+     complain.  */
+  state &= 0xFF88;
+  STD_API_CALL
+    (dos_set_fh_state, (handle, (state | OPEN_FLAGS_NOINHERIT)));
+}
 \f
 void
 OS_channel_close (Tchannel channel)