As tilly and toma pointed out, error checks might be useful; to quote approximately from Camel, 2nd edition:

"""
Always check the return values of system calls.
Always check the return values of system calls.
ALWAYS CHECK THE RETURN VALUES OF SYSTEM CALLS!
"""

Which I of course forgot to do. Oops. Will add error checks and reply again if I still can't figure out the problem.

Update: Well, that didn't seem to be the problem, because I added checks, and a wait (marked by ##):

$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] or die "Can't open2 \"${\($processes{$process}[0])}\": $!, $? +, $^E; stopped"; ## select(IN) or die "Can't select IN: $!, $?, $^E; stopped"; ## for (;;) { my $piece = join '', map { my $x; (eof $_) ? "\0" : (defin +ed ($x = <$_>) ? $x : ( die "Can't read: ", ## "$!, $?, $^E; stopped" )) } @fh; (grep { not eof $_ } @fh) ? (print($piece) or die "Can't print: $!, $?, $^E; stopped") # +# : (last); } close (IN) or die "Can't close IN: $!, $?, $^E; stopped"; ## return \*OUT; } } } keys %processes }; tie %river, 'Data::Flow', $water; $SIG{CHLD} = sub { wait }; ## { my $output = $river{$final}; local $/ = undef; local $_; defined($_ = <$output>) or die "Can't read: $!, $?, $^E; stopped"; + ## print or die "Can't print: $!, $?, $^E; stopped"; ## } exit 0;
... and it no longer hangs at first, but then the pipes break, spilling data everywhere, and it hangs:
C:\premchai21\perl>perl multipipe.pl -f pipes
-p destination: Broken pipe
-p destination: Broken pipe
#kill.#
#darn!  killed emacs instead#
#kill!#
C:\premchai21\perl>
Tried it with a smaller set, "tiny", listed:
process cat perl -spew
start cat
final cat
Prompt transcript (read STDIN ok, ##s are what I type but don't see):
C:\premchai21\perl>perl multipipe.pl -f tiny
hello, world!
#^Z, RET#
#^Z, RET#
#^Z^Z^Z^Z^Z^Z^Z^Z^Z#
 at multipipe.pl line 102.

C:\premchai21\perl>
Line 102 is the line with the defined test on the read from $output, third from the end. So something seems to be wrong with the read, but as the die didn't function properly, I still can't tell exactly what's wrong. Was hoping for a more informative error message, which I didn't get.

Anyone?


In reply to Re: Deadlock occurring, reason unknown by premchai21
in thread 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.