After the slave end is used (open(), read(), write(), close()), the master's read() finishes and returns with an EIO error. But I was expecting to be able to open()/close() multiple times the slave end without disrupting the master fd.Is it possible to keep the two ends valid after the slave's close()? How can I keep my master program running when the slave end is closed? Am I supposed to re-run to entire grantpt(); unlockpt(); ptsname(); sequence?
Is it possible to reuse the slave end of a PTY after closing it?
linux;pty
Short: noLong: a pseudo-terminal slave connection is one end of a connection, like a pipe.  Both are ways that data is passed back and forth between user processes through the kernel.Once one end is closed, you lose the connection.  The ptsname description in POSIX says:Upon failure, ptsname() shall return a null pointer. This could occur if fildes is an invalid file descriptor or if the slave device name does not exist in the file system.Once you close a file descriptor, it is invalid.If you want to reuse a connection, you could do some workaround such as passing the open slave file descriptor to a newly-created process, e.g., from a server application which you write to manage the slave file descriptors.Further reading:7.2 Pseudo Terminals  (Text Terminal HOWTO)close - close a file descriptor (POSIX)grantpt - grant access to the slave pseudo-terminal device (POSIX)pipe - create an interprocess channel (POSIX)ptsname - get name of the slave pseudo-terminal device (POSIX)unlockpt - unlock a pseudo-terminal master/slave pair (POSIX)