phar-io/phive

Phive reports broken pipe when writing to closed standard output (STDOUT)

ktomk opened this issue · 0 comments

ktomk commented

Phive 0.15.2 (also 0.15.1) is talkative when passing output into head(1) and similar utilities:

$ phive --version | head -n 1
Phive 0.15.2 - Copyright (C) 2015-2023 by Arne Blankerts, Sebastian Heuer and Contributors
[ERROR]   An error occurred while processing your request:

          fwrite(): write of 1 bytes failed with errno=32 Broken pipe
          
          #0 src/shared/cli/output/ConsoleOutput.php(49)
          #1 unknown file(0): PharIo\Phive\Cli\Runner->errorHandler()
          #2 src/shared/cli/output/ConsoleOutput.php(49): fwrite()
          #3 src/shared/cli/Runner.php(192): PharIo\Phive\Cli\ConsoleOutput->writeText()
          #4 src/shared/cli/Runner.php(242): PharIo\Phive\Cli\Runner->showFooter()
          #5 src/shared/cli/Runner.php(95): PharIo\Phive\Cli\Runner->execute()
          #6 (354): PharIo\Phive\Cli\Runner->run()
          #7 {main}

          Environment: PHP 7.4.33 (on Linux 5.15.0-60-generic)
          Phive Version: 0.15.2

          This should not have happened and is most likely a bug.
          Please report it at https://github.com/phar-io/phive/issues, make sure you include
          the full output of this error message. Thank you!

Reported per request in the message.

  • Workaround:

    phive ... 2>/dev/null | head -n 1
              ###########
    
  • Additional Info:

    IMHO the warning is not necessary in this case. I could not find any verbose or quiet switches, no idea how this is handled on utility level. I normally allow failures writing to standard output ignoring broken pipe if it was available at initialization (e.g. @fwrite(STDOUT, ...)), YMMV.