[ralda at gmx.de: computer phenomena: output of tty applet]

Rich Felker dalias at aerifal.cx
Tue Apr 3 02:49:44 UTC 2012


On Tue, Apr 03, 2012 at 04:03:14AM +0200, ralda at gmx.de wrote:
> Ok, I know, reading the link needs access to proc filesystem but which
> Linux system do not enable that access in it's early boot stage? And
> if proc is really not available (in the early boot process) the
> call to ttyname may just fail with an error which let tty complain with
> "not a tty". At that time you usually know your tty (/dev/console) and
> the test "[ -t 0 ]" still works right. IMHO a good case how to save
> time and space in uClibc. May be with a configurable option if readlink
> is used or the scan loop, with a Linux default of readlink.

Perhaps a more robust solution would be to do this:

1. Try /proc if it works.

2. Fallback to fstat() to read the major/minor number for stdin, and
use that to construct a candidate pathname based on standard naming
rules. stat() the pathname, and if they match, use it.

3. Finally (optional; personally I would omit this step because it's
bloated and ugly) scan /dev for a matching device.

Rich


More information about the busybox mailing list