in reply to close $fh fails on a single host - looking for explanation

Looks to me like a RAID issue. Has the server in question had disk/controller problems? I don't think this a perl issue.

Update: for context Reconstruction:

"In short: quite often you get a temporary failure of several disks at once; afterwards the RAID superblocks are out of sync and you can no longer init your RAID array."

  • Comment on Re: close $fh fails on a single host - looking for explanation

Replies are listed 'Best First'.
Re^2: close $fh fails on a single host - looking for explanation
by Monk::Thomas (Friar) on Feb 13, 2014 at 11:27 UTC

    The server had a disk problem in the past. Hmm. The command's exit code is 16. Could this provoke perl into closing the filehandle automagically?

    I wasn't expecting perl to close a pipe-filehandle on a non-zero exitcode1, but that would explain what is going on: Can't close a non-existing filehandle.

    1 My assumption: Either always close a pipe after exhausting the input or always leave it open.

    P.S.: The raid has been rebuild successfully. The controller is just complaining that the failed disk has not been properly removed from it's configuration yet.

      CONFIRMED. The non-zero exit code is the culprit.

      implemented solution:
      open my $fh, '-|', "$command || true"

      alternative solution: do not close the filehandle

        Hi,

        culprit is the wrong term, because this is intended behaviour on UNIX like systems. Many people don't know that, but the return code of the command at the pipe sink is propagated through the return code of the close on that filehandle.

        Therefore it is not the best solution avoiding to close the filehandle, but be prepared for the valid return values.

        Hava a look at man 2 close and perldoc -f close.

        Best regards
        McA