Added condition to prevent 'write EPIPE' error on sunos