getpt() opens a pseudoterminal master always returns 0

Solution Verified - Updated -

Issue

We use getpt () to open the pseudo terminal master. In one of our applications this always returns 0.

Strace traces also showed the same:

open("/dev/ptmx", O_RDWR)               = 0

Code snippet:

fd = getpt (); // open the pseudo terminal master

if (fd >= 0) { 
   ..
}
else {
   return "Could not get pseudo terminal";
}

On the live system we are going into the else part. Please let me know why the api is returning 0.

Environment

  • Red Hat Enterprise Linux

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In