From: Thorsten Meinecke <kaefer@aglaia.aball.DE>
To: zsh-workers@math.gatech.edu
Subject: Why's ttyname() called twice on start-up?
Date: Thu, 19 Sep 1996 20:02:58 +0200 (MET DST) [thread overview]
Message-ID: <m0v3nRD-00008PC@aglaia.aball.DE> (raw)
Being bored the other day, I played a little with strace(1).
Even if zsh runs non-interactively, invoked for example by
% strace -f zsh -fc exit
I discovered to my astonishment a plethora of readdir() calls, all
skimming through the /dev directory, not only once, but three times!
Turns out that with my old Linux kernel 1.2.13 and libc 5.0.9, the
ttyname() function seems to be costly implemented. Things improved
since then, under, say, 2.0/5.2.18 only a few getdents() system calls
are needed instead of several hundred readdir()s. Ignoring the fact
that the implementation of ttyname() is highly system-specific, and
its efficiency may vary - can't the second call to it be avoided?
[With Linux, it's called a third time anyway, internally by getlogin()]
init_io () at init.c:318 (this is 3.0.0)
318 SHTTY = movefd(open(ttyname(0), O_RDWR));
...
setupvals () at init.c:520
520 if (!(ttystrname = ztrdup(ttyname(SHTTY))))
Regards,
--Thorsten
reply other threads:[~1996-09-19 18:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m0v3nRD-00008PC@aglaia.aball.DE \
--to=kaefer@aglaia.aball.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).