2012/12/10 Lionel Cons <[email protected]>:
> 2012/11/28 Clark WANG <[email protected]>:
>> ~{fd} is new to me. Please help me a bit...
>>
>>>
>>> >>>
>>> >>> This isn't readlink support. It's a a smart solution to allow child
>>> >>> processes to access the shell's inherited file descriptors.
>>
>>
>> Lionel, I don't quite understand this. Can you explain a bit more?
>
> ksh does not share fds with it's child processes. However with
> /proc/$PPID/fd/number (ksh uses /dev/fd instead of /proc if the latter
> is not available) it is possible to access the fds of the ksh parent
> process. ksh93 gives an easy abstraction of this feature using ~{fd}.
The other very IMPORTANT usage of ~{fd} is to shorten paths. Imagine a
directory with a very long path like
/data/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/data/run/lock/
on which around 5000000 open() calls are executed by different
applications started from the shell. My staff figured that on a
heavily loaded machine using ~{fd}, pointing to /proc/pid/fd/number
instead of
/data/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/1/2/3/8/7/2/9/data/run/lock/
will give a major performance advantage because the kernel no longer
has to parse and walk the gargantuan path each time and keeping the
directory open will cause the file name cache (DNLC) to keep the
directory name and contents "hot" in it's cache.
>
> Lionel
Lionel
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users