Hi,

This patches changes the available file descriptors when starting
translator processes. It keeps stdin and stdout open, both pointing to
/dev/null.
This patch has the side effect of fixing the strange behavior of CLISP
when starting Lisp translators (it goes into a stack overflow with
stdin and stdout closed).

Notes on new headers:
- fcntl.h: O_READ, O_WRITE
- paths.h: _PATH_DEVNULL

Index: start-translator.c
===================================================================
RCS file: /sources/hurd/hurd/libfshelp/start-translator.c,v
retrieving revision 1.5
diff -u -r1.5 start-translator.c
--- start-translator.c  30 Jan 2001 23:45:32 -0000      1.5
+++ start-translator.c  28 Jul 2008 20:01:50 -0000
@@ -20,6 +20,8 @@

 #include "fshelp.h"
 #include <unistd.h>
+#include <fcntl.h>
+#include <paths.h>
 #include <string.h>
 #include <hurd.h>

@@ -43,6 +45,8 @@
   ports[INIT_PORT_CWDIR] = getcwdir ();
   ports[INIT_PORT_CRDIR] = getcrdir ();
   ports[INIT_PORT_AUTH] = getauth ();
+  fds[STDIN_FILENO] = file_name_lookup (_PATH_DEVNULL, O_READ, 0);
+  fds[STDOUT_FILENO] = file_name_lookup (_PATH_DEVNULL, O_WRITE, 0);
   fds[STDERR_FILENO] = getdport (STDERR_FILENO);

   err = fshelp_start_translator_long (underlying_open_fn, cookie,
Index: start-translator.c
===================================================================
RCS file: /sources/hurd/hurd/libfshelp/start-translator.c,v
retrieving revision 1.5
diff -u -r1.5 start-translator.c
--- start-translator.c	30 Jan 2001 23:45:32 -0000	1.5
+++ start-translator.c	28 Jul 2008 20:01:50 -0000
@@ -20,6 +20,8 @@
 
 #include "fshelp.h"
 #include <unistd.h>
+#include <fcntl.h>
+#include <paths.h>
 #include <string.h>
 #include <hurd.h>
 
@@ -43,6 +45,8 @@
   ports[INIT_PORT_CWDIR] = getcwdir ();
   ports[INIT_PORT_CRDIR] = getcrdir ();
   ports[INIT_PORT_AUTH] = getauth ();
+  fds[STDIN_FILENO] = file_name_lookup (_PATH_DEVNULL, O_READ, 0);
+  fds[STDOUT_FILENO] = file_name_lookup (_PATH_DEVNULL, O_WRITE, 0);
   fds[STDERR_FILENO] = getdport (STDERR_FILENO);
 
   err = fshelp_start_translator_long (underlying_open_fn, cookie,

Reply via email to