in reply to Segmentation Fault - Child/Output collision?

Here's the important parts of the code...

open OUTLOG, ">$outlog_filename" or die "$!"; open ERRLOG, ">$errlog_filename" or die "$!"; chdir "$src_dir/src"; #Runs the make, sending output to logs. FAKEHANDLE is a closed filehan +dle. open3( \*FAKEHANDLE, ">&OUTLOG", ">&ERRLOG", "$make_cmd -v -f $makefil +e" ); close OUTLOG; close ERRLOG;
/ Stormr

Replies are listed 'Best First'.
Re: Re: Segmentation Fault - Child/Output collision?
by ariels (Curate) on Aug 07, 2001 at 15:45 UTC
    From perldoc IPC::Open3:
    It will not create these file handles for you. You have to do this yourself. So don't pass it empty variables expecting them to get filled in for you.
    So you can't pass FAKEHANDLE like you do; instead, you'd need to open /dev/null for reading and pass that.

    However, if as in your example you're not interested in communicating with your process as it runs, why not just say

    system("$make_cmd -v -f $makefile > $outlog_filename 2> $errlog_filena +me")
    instead?

      Clarifying: FAKEHANDLE *is* a real filehandle, as said in the comment ("FAKEHANDLE is a closed filehandle"), so it runs just fine. I didn't include the code lines treating it though, as I found them rather redundant.

      Unfortunately system() does just the same thing here as my IPC::Open3 call, and as well as being an equally nice bit of code (nicer?), it doesn't prevent the segmentation fault.

      / Stormr
Re: Re: Segmentation Fault - Child/Output collision?
by tachyon (Chancellor) on Aug 07, 2001 at 15:42 UTC

    If all you want to do is captrue the output of the $make_cmd and send it to your log files why not just use backtics and do this:

    my $output = `$make_cmd -v -f $makefile`; print OUTLOG $output;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print