Why use pwd(1) for getpwd(3C)? (Re: Why use find?)

Tom Christiansen tchrist at convex.COM
Sun Oct 14 04:47:07 AEST 1990


In article <1990Oct13.121552.3878 at virtech.uucp> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>TOTALS    646704     1876.70   2071.13    907889.81    0.91    0.00    0.00 
>pwd          689        1.90      0.61         2.72    3.10    0.00    0.22
>
>Note that only 689 pwd's were run in an entire month.  This includes
>command line pwds that weren't built-in to the respective shells, all
>calls to getcwd, etc.

Well, on my system, I've got around twice your total of commands (1.2meg), 
but I've got 8000 calls to pwd, plus 27000 calls to the csh, who runs a
getwd() when he starts up.  I'm glad my system doesn't do the fork/exec
to get its working directory.

But I agree that "massively" faster is probably an overstatement.  Programs
shouldn't need to do more than one of these per run.

I'm not expecting to lose the permissions on an enclosing directory very 
much.  If anything, I'd be concerned about losing the very directory 
itself, something that a suid pwd won't solve.

--tom



More information about the Comp.unix.programmer mailing list