microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.46k stars 235 forks source link

Can pty clear the previous data #496

Closed ghost closed 2 years ago

ghost commented 2 years ago

Environment details

Issue description

I tried to use pty.spawn to create a pty, and then use the socket connection on the front end to get the output of the pty and display it on Xterm. The current phenomenon is that when I use another socket to connect to the pty, the data I get contains the data generated by the first socket operation pty. Does the opened pty have an API to clear the cache?

jerch commented 2 years ago

Not sure what you are trying to achieve, it either sounds like you want to have multiple independent terminal connections (use multiple pty objects for that), or you want to multiplex a single terminal connection (then mirroring is the wanted behavior).

Does the opened pty have an API to clear the cache?

Nope, there is no such cache that could be cleared. I suggest to read into TTY/PTY (posix) and ConPty (windows) semantics before trying to build more complex solutions.