After upgrading to Perl 5.24.4 we repeatedly get this error in logs (without pointing the filename and line number):
Unable to flush stdout: Broken pipe
We have no idea what causes this error.
Is there any advice how to understand the cause of the error?
Broken pipe
is the error string associated with system errorEPIPE
. One receives this error when writing to a closed pipe. Writing to a closed pipe usally results in the process being killed by a SIGPIPE, so it means the behaviour of SIGPIPE was changed from its default.As melpomene discovered, the error is automatically output if you write to a broken pipe in an
END
block.This isn't necessarily a problem, although it could be a sign that a process is exiting prematurely.
The error comes from perl.c, line 595:
This line is part of
perl_destruct
, which is called to shut down the perl interpreter at the end of the program.As part of the global shutdown procedure, all still open filehandles are flushed (i.e. all buffered output is written out). The comment above says:
The error message is not listed in
perldoc perldiag
, which is arguably a documentation bug. It was probably overlooked because it's not a realwarn
ordie
call, it's effectively justprint STDERR $message
. It's not associated with a file name or line number because it only happens after your program stops running (i.e. after a call toexit
or because execution fell off the end of the main script).This is very general advice, but
at the top of the script, or running with
will get Perl to produce stack traces with every warning and error.