The following code fragment is part of a nagios check that is running on about 70 hosts. There's one host which fails the close() and I don't know why. Maybe some exotic edge case?
use strict; use warnings; require 5.008_008; use Carp; use English qw( -no_match_vars ); [...] open my $fh, '-|', "$command" or carp "Error while executing command:$ERRNO\n"; my @command_output = <$fh>; close $fh or carp "ERROR: Couldn't close filehandle: $ERRNO\n";
(I'm wondering why there's carp instead of croak, but that's a different issue.)

The open/close is part of a subroutine, $command is provided as a parameter. In this case it's "LC_ALL=C sudo mpt-status --newstyle --probe_id" and the command output is:

Checking for SCSI ID:0 ioc:0 vol_id:0 type:IM raidlevel:RAID-1 num_disks:2 size(GB):148 state +: OPTIMAL flags: ENABLED ioc:0 phys_id:1 scsi_id:8 vendor:ATA product_id:SAMSUNG HE160HJ +revision:0-24 size(GB):149 state: ONLINE flags: NONE sync_state: 100 +ASC/ASCQ:0xff/0xff SMART ASC/ASCQ:0xff/0xff ioc:0 phys_id:0 scsi_id:1 vendor:ATA product_id:ST3160812AS +revision:J size(GB):149 state: ONLINE flags: NONE sync_state: 100 +ASC/ASCQ:0xff/0xff SMART ASC/ASCQ:0xff/0xff ioc:0 spare_id:2 scsi_id:255 vendor: product_id: revision: size(GB):14 +9 state: MISSING flags: OUT_OF_SYNC sync_state: n/a ASC/ASCQ:0x00/0x0 +0 SMART ASC/ASCQ:0x00/0x00 scsi_id:1 100% scsi_id:0 100%
The server is running Ubuntu 12.04 LTS, like at least 40 other ones. (The other ones don't exhibit this behaviour.) The installed perl version is 5.14.2-6ubuntu2.4.

ERRATA: I provided the wrong command, it wasn't 'LC_ALL=C sudo mpt-status --controller $id' but 'LC_ALL=C sudo mpt-status --newstyle --probe_id'. The output is/was correct.


In reply to close $fh fails on a single host - looking for explanation by Monk::Thomas

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.