develooper Front page | perl.perl6.users | Postings from August 2022

questions about sigpipe

Marc Chantreux
August 8, 2022 17:19
questions about sigpipe
Message ID:
hello Rakoons,

I found the sigpipe module [S13] while reading the Rakudo Weekly
news[rwn] so Raku can handle SIGPIPE the way I think is the good one:

	raku -e 'loop { say "y"}' | sed 3q
	# some weird error

	raku -Msigpipe -e 'loop { say "y"}' | sed 3q
	# just works


so now I have this 6 wrapper to make raku more unixish:

	6() RAKUDO_ERROR_COLOR= raku -Msigpipe "$@"

RAKUDO_ERROR_COLOR must be set because raku prints escape caracters in
stderr by default, no matter if it is a tty. I never complained about it
but I think of it as a bug.

Also considered as a bug here was the default sigpipe handler

	raku -Msigpipe -e 'loop { say "y"}' | sed 3q

Just works "as expected" and I don't know why Raku took so long to
handle it this way. leont gave me the begin of the answer in the
documentation of the module:

	«Raku's default sigpipe handling does the sensible things for
	networking applications, but entirely the wrong thing for CLI

Can anyone give more detail about it?

Thanks for any answer and regards,

PS: sigpipe is also a nice example of usage for INIT and NativeCall.
Marc Chantreux
Pôle de Calcul et Services Avancés à la Recherche (CESAR) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About