To create a useful pty pair, you must also call grantpt (3) and unlockpt (3) on the fd returned by the open call. It does not specify exactly where in this process the actual slave pty node file is created in the file system - some systems (those where / dev / pts is a special file system, as a rule) create it open, while others will create it as part of a grantpt or unlockpt call. It also does not guarantee that the slave will be in / dev / pts - it could be somewhere else - so you need to call ptsname (3) to find out where it is.
It may also be slightly more portable to call posix_openpt (3) rather than opening directly.
source share