zsh-workers
 help / color / mirror / code / Atom feed
* Why's ttyname() called twice on start-up?
@ 1996-09-19 18:02 Thorsten Meinecke
  0 siblings, 0 replies; only message in thread
From: Thorsten Meinecke @ 1996-09-19 18:02 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-09-19 18:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-19 18:02 Why's ttyname() called twice on start-up? Thorsten Meinecke

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).