Fix infinite wait

Fix a problem that causes infinite wait when executing external app and
waiting for cmd echo