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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content