Special handling for broken pipe cases

Shell's and commands may close STDIN prematurely, the passed shell
binary may not actually be a shell, the script to run as root contains
exit commands. These can lead to broken pipes, which could lead to valid
output not being passed to the application and/or resources not being
released. Some of these cases were already covered, now more are.