At 2026-10-15T21:40:33-0700, Mike wrote:
> mmroff.pl is reporting the sixteen bit value set by wait(2).
> 
> The high order eight bits are the exit status for a process
> terminating normally. If the process is terminated by a fatal signal,
> the low order seven bits indicated that signal. The eighth bit
> indicates whether a core file was generated. This is probably the
> source of confusion about bit 0x80, above.
> 
> In the case in question, mmroff.pl should report $? >> 8. It should
> also detect signal termination and report accordingly.

We already have code to do this in pdfmom.pl (that I put in myself).  I
simply had an attack of laziness and didn't copy it over to mmroff.pl.

sub abort
{
    my $message=shift(@_);
    print STDERR "$prog: fatal error: $message";
    exit 1;
}

sub autopsy
{
    my $waitstatus=shift(@_);
    my $finding;

    if ($waitstatus == -1) {
        $finding = "unable to run groff: $!\n";
    }
    elsif ($? & 127) {
        $finding = sprintf("$groff died with signal %d, %s core dump\n",
            ($? & 127),  ($? & 128) ? 'with' : 'without');
    }
    else {
        $finding = sprintf("$groff exited with status %d\n", $? >> 8);
    }

    return $finding;
}
...
    elsif ($c eq '-v' or $c eq '--version')
    {
        print "GNU pdfmom (groff) version @VERSION@\n";
        my $waitstatus = system("$groff -T$dev --version");
        abort(autopsy($?)) unless $waitstatus == 0;
        exit;
    }

...and so forth.

Regards,
Branden

Attachment: signature.asc
Description: PGP signature

  • ... G. Branden Robinson
    • ... Alexis (surryhill)
      • ... G. Branden Robinson
    • ... Bruno Haible via discussion of the GNU roff typesetting system and related software
      • ... G. Branden Robinson
        • ... John Gardner
          • ... Ingo Schwarze
            • ... Mike
              • ... G. Branden Robinson
                • ... G. Branden Robinson
    • ... Bruno Haible via discussion of the GNU roff typesetting system and related software
      • ... G. Branden Robinson

Reply via email to