[Ecls-list] open-pipe failing on FreeBSD

Julian St. der_julian at web.de
Wed Jul 2 18:00:05 UTC 2003


Hello,

I noticed that every call to si:open-pipe returns NIL, so I looked into the following piece of code (unixsys.d):

cl_object
si_open_pipe(cl_object cmd)
{
  FILE *ptr;
  cl_object stream;

  assert_type_string(cmd);

-> if ((ptr = popen(cmd->string.self, OPEN_R)) == NULL) <-
    @(return Cnil)   
...


In si_open_pipe popen is used to create a pipe:

FILE *
     popen(const char *command, const char *type);

The problem is the type OPEN_R which is "rb". That seems to cause trouble, as every call to popen fails, unless one substitutes OPEN_R with "r" dropping the "b". The popen man page does not mention a "b" as type flag.

Perhaps all OPEN_* constants defined in internal.h should be without the "b" on FreeBSD, since the "b" is ignored anyway:

(taken from fopen man page)
The mode string can also include the letter ``b'' either as a third character or as a character between the characters in any of the two-character strings described above.  This is strictly for compatibility with ISO/IEC 9899:1990 (``ISO C89'') and has no effect; the ``b'' is ignored.


This patch fixes si:open-pipe for me, but I think fixing internal.h is the Right Thing.

cvs server: Diffing .
Index: unixsys.d
===================================================================
RCS file: /cvsroot/ecls/ecls/src/c/unixsys.d,v
retrieving revision 1.12
diff -u -r1.12 unixsys.d
--- unixsys.d   23 Nov 2002 15:42:09 -0000      1.12
+++ unixsys.d   2 Jul 2003 15:40:34 -0000
@@ -43,7 +43,7 @@
 
   assert_type_string(cmd);
  
-  if ((ptr = popen(cmd->string.self, OPEN_R)) == NULL)
+  if ((ptr = popen(cmd->string.self, "r")) == NULL)
     @(return Cnil)
   stream = cl_alloc_object(t_stream);
   stream->stream.mode = smm_input;


Regards,
Julian
-- 
		  Pardon me, your horse is on fire.




More information about the ecl-devel mailing list