3 ms·
> Python is not a good unix citizen in this case. Compare it to Perl for example where nothing special is required to do the right thing How is this better? At
by hk__2 7y ago
> Python is not a good unix citizen in this case. Compare it to Perl for example where nothing special is required to do the right thing
How is this better? At least with the exception you can cleanly terminate your program if you need to.
- hoytech 7y agoIn the unix pipeline model, components read input, perform some transformation, and print output. There is no need to do any clean-up. As nneonneo explained, because they rely on SIGPIPE, most unix programs don't even need to check for errors from write(2). Naturally, in the rare case you want to do some clean-up you can: $ perl -E '$SIG{PIPE} = sub { die "cleanup" }; say "y" while 1' | head -1 y cleanup at -e line 1.