luaposix/luaposix — pull request #58 by sam-github (2013-01-24 01:31:27+00:00)
Title: Support Unix 98 style pseudoterminals, as specified in POSIX.1-2001

Support consists of ptsname(), grantpt(), and unlockpt(). The master
fd should be created by opening /dev/ptmx.

Example usage:
require "posix"
master = assert(posix.open("/dev/ptmx", posix.O_RDWR + posix.O_NOCTTY))
print(master)
name = assert(posix.ptsname(master))
print("slave name", name)
assert(posix.grantpt(master))
assert(posix.unlockpt(master))
slave = assert(posix.open(name, posix.O_RDWR + posix.O_NOCTTY))
print("slave", slave)
print("slave write", posix.write(slave, "bye"))
print("master read", posix.read(master, 3))