[TUHS] UNIX of choice these days?

Chet Ramey chet.ramey at case.edu
Wed Sep 27 01:17:54 AEST 2017


On 9/26/17 10:53 AM, Larry McVoy wrote:
> On Mon, Sep 25, 2017 at 10:06:55PM -0400, Chet Ramey wrote:
>> On 9/25/17 7:49 PM, Dave Horsfall wrote:
>>> On Mon, 25 Sep 2017, Larry McVoy wrote:
>>>
>>>> ????????lrwx------ 1 lm lm 64 Sep 23 21:39 255 -> /dev/pts/8
>>>
>>> What the heck is file descriptor 255?
>>
>> It appears to be a file descriptor open to his controlling terminal.
> 
> LOL.  I think he's wondering why the fd has the value of 255 and I dunno.
> Some weird bash thing?

It's not weird. Bash keeps a file descriptor open to the controlling
terminal to use for job control and other terminal operations. After it
opens the ctty, it dups the file descriptor to something out of the usual
range people use to save and restore fds. It uses the RLIMIT_NOFILE
resource limit to determine the upper bound, but doesn't go past 256 (some
systems set that limit pretty high). So you have a file descriptor that the
shell can use but is close-on-exec and unusual enough to avoid being
stepped on.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet at case.edu    http://cnswww.cns.cwru.edu/~chet/



More information about the TUHS mailing list