Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Upcoming /bin/sh (mostly internal) change

kre%munnari.OZ.AU@localhost (Robert Elz) writes:

>I really couldn't believe the 2 seconds of system time for the old (which
>means, NetBSD current) shell, there should be nothing in there that could
>rationally consume any system time

That's two isatty() calls (== ioctl TIOCGETA) per arith expression.

#0  _isatty (fd=0) at /home/netbsd-current/src/lib/libc/gen/isatty.c:54
#1  0x000000002581ab6d in yy_init_buffer (b=b@entry=0x79fda7b3a070, 
    file=file@entry=0x79fda776c160 <__sF>) at arith_lex.c:1505
#2  0x000000002581abe6 in yy_create_buffer (file=0x79fda776c160 <__sF>, 
    size=size@entry=16384) at arith_lex.c:1458
#3  0x000000002581af60 in yylex () at arith_lex.c:733
#4  0x000000002581a2aa in yyparse () at arith.c:640
#5  0x000000002581a63e in arith (s=<optimized out>)
    at /home/netbsd-current/src/bin/sh/arith.y:135

If I look at flex sources, it's difficult to avoid, because in
yy_init_buffer() you find:

        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;

which is called with file == yyin and in yylex() a NULL value is
overriden with stdin.

                if ( ! yyin )
                        yyin = stdin;

                                Michael van Elst
                                "A potential Snark may lurk in every tree."

Home | Main Index | Thread Index | Old Index