man.bsd.lv manual page server

Manual Page Search Parameters

POSIX_OPENPT(3) Library Functions Manual POSIX_OPENPT(3)

posix_openptopen a pseudo-terminal device

library “libc”

#include <stdlib.h>
#include <fcntl.h>

int
posix_openpt(int oflag);

The () function searches for an unused master pseudo-terminal device, opens it, and returns a file descriptor associated with the now used pseudo-terminal device. The oflag argument has the same meaning as in the open(2) call.

If successful, posix_openpt() returns a non-negative integer, which corresponds to a file descriptor pointing to the master pseudo-terminal device. Otherwise, a value of -1 is returned and errno is set to indicate the error.

ioctl(2), open(2), grantpt(3), ptsname(3), unlockpt(3)

The standards committee did not want to directly expose the cloning device, thus decided to wrap the functionality in this function. The equivalent code would be:

	int
	posix_openpt(int oflag) {
		return open("/dev/ptmx", oflag);
	}

The posix_openpt() function conforms to IEEE Std 1003.1-2001 (“POSIX.1”).

May 25, 2004 NetBSD-9.2