[svn:parrot] r38754 - in trunk: src/io src/pmc t/op

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed May 13 19:19:10 UTC 2009


Author: NotFound
Date: Wed May 13 19:19:09 2009
New Revision: 38754
URL: https://trac.parrot.org/parrot/changeset/38754

Log:
[core] fix open pipe for write on linux, add a test for it

Modified:
   trunk/src/io/unix.c
   trunk/src/pmc/filehandle.pmc
   trunk/t/op/io.t

Modified: trunk/src/io/unix.c
==============================================================================
--- trunk/src/io/unix.c	Wed May 13 18:17:33 2009	(r38753)
+++ trunk/src/io/unix.c	Wed May 13 19:19:09 2009	(r38754)
@@ -654,8 +654,8 @@
         else
             io = filehandle;
 
-        Parrot_io_set_flags(interp, filehandle,
-                (Parrot_io_get_flags(interp, filehandle) & PIO_F_PIPE));
+        Parrot_io_set_flags(interp, io,
+                (Parrot_io_get_flags(interp, io) & (~PIO_F_PIPE)));
 
         if (flags & PIO_F_READ) {
             /* close this writer's end of pipe */
@@ -689,7 +689,7 @@
         if (flags & PIO_F_WRITE) {
             /* the other end is writing - we read from the pipe */
             close(STDIN_FILENO);
-            close(fds[1]);
+            /*close(fds[1]);*/
 
             if (Parrot_dup(fds[0]) != STDIN_FILENO)
                 exit(EXIT_SUCCESS);

Modified: trunk/src/pmc/filehandle.pmc
==============================================================================
--- trunk/src/pmc/filehandle.pmc	Wed May 13 18:17:33 2009	(r38753)
+++ trunk/src/pmc/filehandle.pmc	Wed May 13 19:19:09 2009	(r38754)
@@ -225,6 +225,7 @@
         }
 
         flags = Parrot_io_parse_open_flags(interp, open_mode);
+        SET_ATTR_flags(INTERP, SELF, flags);
         filehandle = PIO_OPEN(INTERP, SELF, open_filename, flags);
 
         if (PMC_IS_NULL(filehandle))

Modified: trunk/t/op/io.t
==============================================================================
--- trunk/t/op/io.t	Wed May 13 18:17:33 2009	(r38753)
+++ trunk/t/op/io.t	Wed May 13 19:19:09 2009	(r38754)
@@ -7,7 +7,7 @@
 use lib qw( . lib ../lib ../../lib );
 
 use Test::More;
-use Parrot::Test tests => 3;
+use Parrot::Test tests => 4;
 
 =head1 NAME
 
@@ -88,6 +88,42 @@
 CODE
 /This is Parrot.*/
 OUTPUT
+
+pir_output_is( <<'CODE', <<'OUTPUT', 'open pipe for writing' );
+.include 'iglobals.pasm'
+
+.sub testreadpipe :main
+  .local pmc interp
+  interp = getinterp
+  .local pmc conf
+  conf = interp[.IGLOBALS_CONFIG_HASH]
+  .local string command
+  command = conf['build_dir']
+  .local string aux
+  aux = conf['slash']
+  command .= aux
+  .local string filename
+  filename .= command
+  filename .= 'examples/pasm/cat.pasm'
+  aux = conf['test_prog']
+  command .= aux
+  aux = conf['exe']
+  command .= aux
+  command .= ' '
+  command .= filename
+
+  .local pmc pipe
+  pipe = open command, 'wp'
+  unless pipe goto failed
+  pipe.'puts'("Hello, pipe!\n")
+  .return()
+failed:
+  say 'FAILED'
+.end
+CODE
+Hello, pipe!
+OUTPUT
+
 }
 
 # Local Variables:


More information about the parrot-commits mailing list