fix #432 wait to flush process output