I have to create a new pair of tty (master and slave) without using forkpty().
In the man of pts(4), it is written that :
When a process opens /dev/ptmx, it gets a file descriptor for a pseudo-terminal master (PTM), and a pseudo-terminal slave (PTS) device is created in the /dev/pts directory.
With a little program in C, I open /dev/ptmx like that :
open("/dev/ptmx", O_RDWR);
But there is no new pty created in /dev/pts/.
To actually create a usable pty pair, you must also call grantpt(3) and unlockpt(3) on the fd returned by the open call. Its not well-defined exactly where in that process the actual slave pty file node in the filesystem is created -- some systems (those where /dev/pts is a special filesystem, usually) will create it on the open, while others will create it as part of the grantpt or unlockpt call. Its also not guarenteed that the slave will be in /dev/pts -- it might be somewhere else -- so you need to call ptsname(3) to find out where it is.
It also may be slightly more portable to call posix_openpt(3) rather than open directly.