pseudo-terminal masters

Bill McGonigle bill at bfccomputing.com
Wed Jan 14 01:26:19 EST 2009


On 2009-01-13 10:36 PM, Ben Scott wrote:
>
>    Pure speculation, but I would guess that the TMOUT variable is
> implemented just by having the shell call alarm(2) and then catching
> SIGALRM.  Otherwise the shell would have to poll its own input channel
> constantly to see if it was idle, which would be kinda inefficient.

Well, the shell is in a unique position here in that it's directly 
allocating the master and slave pty, so it can just do, e.g. 
master_last_time = time() whenever it writes to the master and have the 
alarm callback check that.  Programs outside the shell are a bit less 
privileged there.

I've looked at a few c examples of opening the master and slave, and so 
far can't figure out why the master file descriptor doesn't show up in 
the lsof for a shell.

-Bill

-- 
Bill McGonigle, Owner           Work: 603.448.4440
BFC Computing, LLC              Home: 603.448.1668
bill at bfccomputing.com           Cell: 603.252.2606
http://www.bfccomputing.com/    Page: 603.442.1833
Blog: http://blog.bfccomputing.com/
VCard: http://bfccomputing.com/vcard/bill.vcf


More information about the gnhlug-discuss mailing list