The perl script itself is the wrapper to the program. I have gotten to this stage now

#!/usr/bin/perl -w use POSIX qw(:signal_h :errno_h :sys_wait_h); $command = $ARGV[0]; parse(); if (!defined ($pid = fork())) { die "cannot fork: $!"; } elsif ($pid == 0) { exec("$command"); } else { waitpid($pid, 0); if (WIFEXITED($?)) { print "Exited\n"; } elsif (WIFSIGNALED($?)) { $sig = WTERMSIG($?); if ($sig == 11) { print "Segfault\n"; exit 11; } print "Signaled $sig\n"; } else { print "EH\n"; } } close STDOUT; exit 0; sub parse { my $pid; return if $pid = open(STDOUT, "|- "); die "cannot fork: $!" unless defined $pid; while (my $line = <STDIN>) { print "$line"; } exit; }
So I am able to capture the program and take note of when it segfaults, and also parse the programs standard out. All I am missing now is capturing the programs stderr...

Apart from using IO::Capture is there another way that will simply add to the above code, or is this just wishful thinking?

Thank you very much to everyone who have replied to my question.


In reply to Re^2: Capturing stdout and segfault of a program by Gmong
in thread Capturing stdout and segfault of a program by Gmong

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.