Hello.
I am a bit hair sore about the second comment. But if you put it that way. But still I want to say, that I produce stuff, when I have good ideas, (in my own mind), and I test it, as duly, as I think proper, when I write it. But, occasionally, it do happen that I haven’t thought of everything, when I post it. And if people then discover a bug, then they are welcome to say that, and I’ll fix it, but some staged/planned testing of everything, that is not going to happen, there is no room for that. The alternative is to not post here. I am careful to make stuff work under the conditions I see, as good as possible. But sometimes, I have to stop somewhere, with a quality I can live with (SafariSearchTabs). If someone then want something more, they are welcome to either fix it themselves, and share the result, or send me money!
As for the first one, you really create a pty device, by using some pty mechanism, you can read about in Advanced Unix Programming, the reason for doing so, is to give programs that run in shells, the impression that they still are having, at least an equivalent to a tty. It is like setting up a primitive server, so you can get at the input and output of the streams. (It works the same way as the program you use for recording input output of a shell in a terminal window.
Try ls /dev/pty/*
The article at Wikipedia aren’t that good in this case.
I have actually programmed a pseudo terminal, and to me, using a pseudo terminal is to emulate a terminal device through files. I’ll keep you informed if I upload the code to github.