I am writing a program which will allow the user to create a system of pipes in a text file, which can then be interpreted and executed, with a bunch of processes, and one or more inputs and one output for each process, which may be linked to STDIN, STDOUT, another process, or nowhere. (I'm planning to include possibilities for more than one output for each process, capturing / outputting to STDERR, etc. but I need to fix this version before adding anything.) However, deadlock is occurring for no apparent reason. The relevant code:
$water = { map { my $process = $_; my @inputs = @ {$processes{$process}[1]}; $_, { prerequisites => [ @inputs ], oo_output => sub { my ($data) = shift; my ($pid, @fh, $active); @fh = map { $data->get($_) } @inputs; push @fh, \*STDIN if ((defined $start) and $start eq $ +process); $active = scalar @fh; local (*IN, *OUT, $/, $\); $/ = 1; $\ = ''; open2 \*OUT, \*IN, $processes{$process}[0]; select(IN); for (;;) { my $piece = join '', map { (eof $_) ? "\0" : <$_> } @fh; (grep { not eof $_ } @fh) ? (print $piece) : (last); } close (IN); return \*OUT; } } } keys %processes }; tie %river, 'Data::Flow', $water; { my $output = $river{$final}; local $/ = undef; local $_; $_ = <$output>; print; } exit 0;
... where the Data::Denter patterns of the variables are approximately:
# \%processes
%
    <name> => @
        <command>
        @
            <inputs' names, one per element>

# \@pipes
@
    @
        <from>
        <to>

# $start
<which process connects to STDIN>
# $final
<which process connects to STDOUT>
... and the data file:
process 1stcat perl -spew ..\gismu.text
process 2ndcat perl -spew ..\cmavo.text
process 3rdcat perl -spew
pipe 1stcat 3rdcat
pipe 2ndcat 3rdcat
final 3rdcat
... and a prompt transcript under Win32 (#s are special actions):
C:\premchai21\perl>perl multipipe.pl -f pipes
#hang #
#kill.#
-p destination: Broken pipe
-p destination: Broken pipe
#hang #
#kill!#
C:\premchai21\perl>
I tried it in the Perl debugger too, but it was rather unhelpful. What is going wrong? Running ActiveState Perl 5.6.0, build 623, on Win98.

In reply to Deadlock occurring, reason unknown by premchai21

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.