Bug #19578
closedabort() shows stack trace when run within rescue clause
Description
I sometimes use the pattern print(str) rescue abort
in order to exit without stack trace when the output of a ruby program is interrupted by SIGPIPE, ex: ./printstuff.rb | head
It seems that since ruby 2.7 this results in printing the stack trace. This is not the case when using abort
by itself.
Is this intended? I would expect abort
to behave much like exit(1)
, as it always has.
Updated by jeremyevans0 (Jeremy Evans) over 1 year ago
- Status changed from Open to Rejected
This was a deliberate change, see #16424.
Updated by Dan0042 (Daniel DeLorme) over 1 year ago
Thank you, I searched but wasn't able to find it.
But in that case I think the documentation should be updated. This:
Terminate execution immediately, effectively by calling Kernel.exit(false). If msg is given, it is written to STDERR prior to terminating.
reads to me like nothing is written to STDERR if msg is not given. Perhaps update to something like:
Terminate execution immediately, effectively by calling Kernel.exit(false). If msg is given, it is written to STDERR prior to terminating. Otherwise, if an exception was raised, print its message and backtrace.
Updated by jeremyevans0 (Jeremy Evans) over 1 year ago
Dan0042 (Daniel DeLorme) wrote in #note-2:
But in that case I think the documentation should be updated.
I agree. Can you please submit a pull request for it?
Updated by nobu (Nobuyoshi Nakada) over 1 year ago
Note that broken pipe on STDOUT error message will not be shown since ruby 3.0. #14413
Updated by Dan0042 (Daniel DeLorme) over 1 year ago
Updated by nobu (Nobuyoshi Nakada) over 1 year ago
Of course, I missed the word "not", sorry.
Updated by Dan0042 (Daniel DeLorme) over 1 year ago
jeremyevans0 (Jeremy Evans) wrote in #note-3:
I agree. Can you please submit a pull request for it?