Improve efficiency of stdout handling in safe_run()

Roman Neuhauser suggested this improvement in handling the stdout from the
subprocess.

Signed-off-by: Jan Blunck <jblunck@infradead.org>