From mboxrd@z Thu Jan 1 00:00:00 1970 From: chet.ramey@case.edu (Chet Ramey) Date: Tue, 26 Sep 2017 11:17:54 -0400 Subject: [TUHS] UNIX of choice these days? In-Reply-To: <20170926145326.GX28606@mcvoy.com> References: <1506341239.18395.for-standards-violators@oclsc.org> <20170925151827.GP28606@mcvoy.com> <646c7556-8300-d4ab-47fd-633352ea18e7@case.edu> <20170926145326.GX28606@mcvoy.com> Message-ID: <5036e22a-c2ef-68b0-0a65-e722804566b4@case.edu> 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/