changeset 5568:1af95f18f709

(Fload): Record descriptor numbers on load_descriptor_list. (load_descriptor_unwind, close_load_descs): New function. (syms_of_lread): Init and staticpro load_descriptor_list. (init_lread): Clear load_descriptor_list.
author Richard M. Stallman <rms@gnu.org>
date Tue, 11 Jan 1994 22:08:34 +0000
parents c61f49e4283a
children b9e2884ca8e6
files src/lread.c
diffstat 1 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lread.c	Tue Jan 11 19:08:24 1994 +0000
+++ b/src/lread.c	Tue Jan 11 22:08:34 1994 +0000
@@ -80,6 +80,9 @@
 /* This is useud to build the load history. */
 Lisp_Object Vcurrent_load_list;
 
+/* List of descriptors now open for Fload.  */
+static Lisp_Object load_descriptor_list;
+
 /* File for get_file_char to read from.  Use by load */
 static FILE *instream;
 
@@ -303,6 +306,7 @@
 
 static void readevalloop ();
 static Lisp_Object load_unwind ();
+static Lisp_Object load_descriptor_unwind ();
 
 DEFUN ("load", Fload, Sload, 1, 4, 0,
   "Execute a file of Lisp code named FILE.\n\
@@ -406,6 +410,9 @@
   *ptr = stream;
   XSET (lispstream, Lisp_Internal_Stream, (int) ptr);
   record_unwind_protect (load_unwind, lispstream);
+  record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
+  load_descriptor_list
+    = Fcons (make_number (fileno (stream)), load_descriptor_list);
   load_in_progress++;
   readevalloop (Qget_file_char, stream, str, Feval, 0);
   unbind_to (count, Qnil);
@@ -431,6 +438,23 @@
   return Qnil;
 }
 
+static Lisp_Object
+load_descriptor_unwind (oldlist)
+     Lisp_Object oldlist;
+{
+  load_descriptor_list = oldlist;
+}
+
+/* Close all descriptors in use for Floads.
+   This is used when starting a subprocess.  */
+
+void
+close_load_descs ()
+{
+  Lisp_Object tail;
+  for (tail = load_descriptor_list; !NILP (tail); tail = XCONS (tail)->cdr)
+    close (XFASTINT (XCONS (tail)->car));
+}
 
 static int
 complete_filename_p (pathname)
@@ -1871,6 +1895,8 @@
   Vvalues = Qnil;
 
   load_in_progress = 0;
+
+  load_descriptor_list = Qnil;
 }
 
 void
@@ -1937,6 +1963,9 @@
     "Used for internal purposes by `load'.");
   Vcurrent_load_list = Qnil;
 
+  load_descriptor_list = Qnil;
+  staticpro (&load_descriptor_list);
+
   Qcurrent_load_list = intern ("current-load-list");
   staticpro (&Qcurrent_load_list);