The way I understand it, here's the way it's supposed to work...

The slashd script is running as a daemon, it calls various housekeeping scripts periodically. The freshenup.pl script gets called by slashd. freshenup.pl contains a call to prog2file() which is used to execute a script and direct the output to a file. prog2file() is executing the script with this line:
$data = `$exec`;
thus capturing the output of the command in a variable which it prints to a file later. The value of $exec at runtime is valid and intended to run article.pl with appropriate arguments.

article.pl runs, and in turn results in a call to index.pl to update the index. index.pl calls slashDisplay() several times and receives the output as a returned value. index.pl then calls slashDisplay() again to print the output instead of return the output. It is this line that is hanging.

So I think the calling order is:

slashd
freshenup.pl
prog2file()
article.pl()
index.pl()

I can run index.pl from the command line using the same arguments with no problem. As far as I see, STDOUT isn't being redirected to any file or socket, etc. I think it's supposed to get to the parent script, and so on up the tree. It's the prog2file() sub that uses the backtick form of the system() command to capture the output of all the children into a scalar and print it to a file.

I'm not fluent enough in this yet to know how to accurately trace the STDOUT path here. I'm told perhaps the parent's pipe has stalled, but I don't know how to investigate that. I didn't write this code, of course, and it's my significant first exposure to perl programming. (slashcode probably isn't the best thing to cut my perl teeth on, but that's the way it's working out!)

In reply to Re: Re: print $out doesn't always? by pumpsoft
in thread print $out doesn't always? by pumpsoft

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.