You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two related issues here, and since this touches all three layers (Rakudo, NQP, vm (e.g. MoarVM)) I wasn't sure where to submit it, but I think NQP, being the glue is the right place to at least ask.
MoarVM does not type exceptions for errno, and we blindly pass those AdHocs up the chain
NQP/Rakudo do not handle EPIPE in a standard way
Using Rakudo from the command-line:
$ perl6 -e 'say 1; say 2' | head -1
1
Unhandled exception: Failed to write bytes to filehandle: Broken pipe
This exception is an AdHoc because it's generated in MoarVM:
MVM_exception_throw_adhoc(tc, "Failed to write bytes to filehandle: %s",
strerror(save_errno));
Which means that code handling routine IO exceptions like this need to string-match the exception text, which is clearly LTA:
put$foo; CATCH { when /'Failed to write bytes to filehandle'/ {exit} }
I believe that the correct solution, here is multi-part:
in the backends, errno should map to typed exceptions (does this require the HLL to provide a set of pre-defined typed exceptions, e.g. X::IO::Pipe at startup, if so, then does NQP have a way to pass those down?)
in NQP or Rakudo (not sure which) the default response to a broken pipe exception should be to exit silently (Perl 5, Python and nearly every other high level language does this, and it's more or less required in order to interoperate cleanly with Unix-like OSes which treat reading all output from a program as strictly optional)
The text was updated successfully, but these errors were encountered:
Funny side-note: I have a vague memory that I may have been the one to report this bug back in the pugs days, or was at least active in explaining the Unix pipeline philosophy when it came up. :-)
There are two related issues here, and since this touches all three layers (Rakudo, NQP, vm (e.g. MoarVM)) I wasn't sure where to submit it, but I think NQP, being the glue is the right place to at least ask.
Using Rakudo from the command-line:
This exception is an AdHoc because it's generated in MoarVM:
Which means that code handling routine IO exceptions like this need to string-match the exception text, which is clearly LTA:
I believe that the correct solution, here is multi-part:
X::IO::Pipe
at startup, if so, then does NQP have a way to pass those down?)The text was updated successfully, but these errors were encountered: