Remove crufty text about use of comma instead of slash to separate
port and protocol. It's not true as at glibc 2.8, and it's not
clear if/when it was ever true.
At the end of the paragraph in opendir(3) describing fdopendir(), I
think it's worth adding "The file descriptor will be closed when
closedir() is called." It's a bit ambiguous if the file descriptor
is closed or "given back" at closedir time.
(I've tested this and verified that it's true, BTW.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
As there are many users who base their own code on these examples,
we should avoid leaking memory when using functions of tsearch() family.
In the provided example, tsearch() leaks memory whenever it tries to
insert a number which was already inserted before.
Also: include use of tdestroy() in example program.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
The error by getpid() in the presence of clone() occurs
only for a fork-like clone (one that omits CLONE_VM from the flags.)
This is a low-level detail, but there is no problem [known-to-me]
for thread-like clone().
The page formerly used both 'dir' and 'dirp'(!).
POSIX.1-2008 and glibc call this argument 'dirp' (consistent
with the fact that it is a *pointer* to a DIR structure).
getpid() caches the PID after the first call. This relies
on support in the glibc wrappers for fork()/vfork()/clone().
However, if syscall() is used to directly invoke fork()/vfork()/clone(),
the cache is not updated, and getpid() in the child procudes the wrong
result.
> > Linux, lstat(2) will generally not trigger automounter action, whereas
> > stat(2) will.
>
> I don't understand this last piece. Can you say some more. (I'm not
> familiar with automounter details.)
An automounter (either an explicit one, like autofs, or an implicit
one, such as are used by AFS or NFSv4) is something that triggers
a mount when something is touched.
However, it's undesirable to automount, say, everyone's home
directory just because someone opened up /home in their GUI
browser or typed "ls -l /home". The early automounters simply
didn't list the contents until you accessed it by name;
this is still the case when you can't enumerate a mapping
(say, all DNS names under /net). However, this is extremely
inconvenient, too.
The solution we ended up settling on is to create something
that looks like a directory (i.e. reports S_IFDIR in stat()),
but behaves somewhat like a symlink. In particular, when it is
accessed in a way where a symlink would be dereferenced,
the automount triggers and the directory is mounted. However,
system calls which do *not* cause a symlink to be dereferenced,
like lstat(), also do not cause the automounter to trigger.
This means that "ls -l", or a GUI file browser, can see a list
of directories without causing each one of them to be automounted.
-hpa