incorrect check for open failure in openpty function