...reading the command's output all at once before closing the pipe.
The problem with this approach is if the pipe's buffer should fill up, you have a deadlock (i.e. the spawned program doesn't exit because it waits for the buffer to be emptied, but this won't happen because you wait for the program to exit). Replace echo BOOM with perl -e"print q(x)x1e5" and you can observe the effect.
In reply to Re^2: capture stdout and stderr from external command
by Eliya
in thread capture stdout and stderr from external command
by pankajadvani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |