Hello.
What I meant that I believe, is that do shell script uses a pty construct, to “hijack” stdin and stdout, when it performs the system calls, in order to intercept stdin, stdout, and stderr. (So the executed shell-utilites behaves as they normally would do, with linebuffering (awk), and what else they need to perform properly.
The way a pty program works, fits beautifully by the way you can send a job to the background with stderr and stdin redirected to /dev/null when you use do shell script by the way. Because then the pty-layer will just return immediately, after having instigated the “job”.
I am not sure (totally) if there are pty’s involved when executing a do shell script, but I find it very natural if there were, as that would have been the easiest way to make the do shell script command work.
Nice blog. 
Edit
I know, a terminal session is also called a pseudo terminal, but if you use the ps command, you’ll see /dev/tty, and you can use ttyname or just tty, to get the tty name.
The ptty’s I am talking about, doesn’t give a /dev/tty back, they won’t work with tty or pty name, but you should be able to find a /dev/pty somewhere.
Well, having written this, I fired up lsof to see, and I didn’t find any pty’s, I did however find either streams, or unix sockets. The streams might be more like System V streams (and there they work with pty’s
). So this question is really open. The technique for implementing a do shell script, should however be much the same way as you would install a pty as layer between shell commands, and the program invoking it, like telnet, rlogin, ssh, session and tpmux. (In principle).