'What's the meaning of writing to /dev/ptmx
I'm reading the source code of sshfs. And I find out that when trying to give the password to ssh, it write the password to /dev/ptmx.
write(sshfs.ptyfd, sshfs.password, strlen(sshfs.password));
I know it's the master side of pseudo-terminal, but I don't really understand meaning of writing to it. I tried to echo something to /dev/ptmx but nothing happened. Maybe I'm not fully understand the mechanism of pts and ptmx.
Solution 1:[1]
The idea of ptmx is that your application creates a virtual console for communication with other applications or with the operating system.
By opening ptmx, an application gets a filed descriptor (basically a number) which gives your application the possibility to communicate over a virtual terminal with other applications.
These other applications can open your terminal by opening /dev/pts/12345 for example.
Echo'ing to /dev/ptmx makes no sense because the only function of /dev/ptmx is to provide your application with a file descriptor of a newly created /dev/pts/ device which can be used by echo.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Florian Sc |
