cleaner way of handling PTY IOErrors