Ticket #661 (closed todo: done)

Opened 13 years ago

Last modified 13 years ago

[TODO] Capture output of subprocesses

Reported by: pmichaud Owned by: allison
Priority: normal Milestone: 1.4
Component: core Version: 1.1.0
Severity: medium Keywords:
Cc: Language: perl6
Patch status: Platform:

Description

As mentioned in  http://lists.parrot.org/pipermail/parrot-dev/2009-April/002067.html, we need some way to be able to run a subprocess and capture its output, similar to Perl 5's backticks.

From today's #parrotsketch:

19:22 <pmichaud> (2) ability to run processes and capture the output -- immediate need for qx{   }  and friends
19:23 <allison> you mean like perl 'system'?
19:23 <pmichaud> yes, or perl 5 backticks
19:23 <moritz> no, like perl's backticks
19:23 <pmichaud> we have 'system' already
19:23 <moritz> system in perl 5 doesn't capture the output
19:23 <pmichaud> (it's called 'run')
19:25 <allison> pmichaud: okay, backticks are the I/O pipe functionality, which does need fixing. IIRC, you have a ticket in for that? 
      If not, put one in and make me owner.  Would be nice to have that working for 1.2.
19:25 <pmichaud> I will make sure there's a ticket with your name on it.

See also RT #62024.

Thanks,

Pm

Change History

  Changed 13 years ago by pmichaud

  • component changed from none to core

follow-up: ↓ 4   Changed 13 years ago by NotFound

Following #parrotsketch and later #parrot comments, I've made an initial fix for Parrot_io_open_pipe in unix platforms and a test for in t/op/io.t, TODOed except for linux because is the only platform I tested.

  Changed 13 years ago by pmichaud

  • lang set to perl6

Just to confirm that this does appear to work fine for unix platforms (Rakudo is now using it), but it doesn't seem to work on Windows platforms. Perhaps Jonathan can provide more details.

Pm

in reply to: ↑ 2   Changed 13 years ago by Infinoid

Replying to NotFound:

Following #parrotsketch and later #parrot comments, I've made an initial fix for Parrot_io_open_pipe in unix platforms and a test for in t/op/io.t, TODOed except for linux because is the only platform I tested.

Thanks for the test. Be advised that I changed the TODO into a SKIP for the 1.2.0 release, because it was inconsistent (it was a TODO pass on some platforms) and because it was leaving background processes running. Those processes all had the command line "parrot <path>/cat.pasm", and would still be running days after the test had completed.

Several of you who have run "make test" in the last few days probably still have these running; try "ps ax | grep parrot" to see those processes, or "killall parrot" to kill them.

Mark

  Changed 13 years ago by NotFound

Adding here now several things commented on the mailing list or forgotten:

- My first comment on this ticket was about pipe reading, the failing test was in the later added pipe writing.

- The pipe function for Windows platforms (except when using cygwin, I think) is in src/io/win32.c and is currently unimplemented.

The problem with write pipes is fixed in r39014, by storing the pid of the child process (reusing the file_size attribute of the filehandle pmc, file size makes no sense for a pipe) and waiting for it on close. I don't unskipped the test yet, waiting for testing on platforms other than linux 32.

  Changed 13 years ago by NotFound

Test unskipped in r39016

  Changed 13 years ago by NotFound

Pipe reading for win32 implemented in r39086. I tested only in XP home, Please give some feedback.

  Changed 13 years ago by NotFound

Pipe writing for win32 implemented in r39099, same comment as for reading.

  Changed 13 years ago by whiteknight

  • milestone changed from 1.3 to 1.4

What more is needed from this ticket, assuming we have pipes working and tested on all major systems?

  Changed 13 years ago by NotFound

  • status changed from new to closed
  • resolution set to done

Closing ticket, it's supposed to be realistically tested by HLL usage.

Note: See TracTickets for help on using tickets.