From: Wietse Venema (no email)
Date: Sun Oct 28 2001 - 14:55:12 EST
> >Does Sendmail support multi-directory queues? If so, how does
> >Sendmail find out if a file name is already in use somewhere?
> >This requires a guaranted unique name, not just O_CREAT|O_EXCL.
> Weitse. You need to relax, slow down & look more. All it takes is an
> fstat() on the filename to see if it already exists... Not pretty maybe,
> but not impossible either.
My question was about multi-directory queues.
As in: each queue file name has to be unique across a number of
different directories, otherwise mail can be lost.
fstat() and access() are not even suitable for single directory
Sendmail/Postfix queues because those functions are subject to race
conditions (official name: TOCTTOU, time of check to time of use).
Instead of fstat() or access() one would use:
open(filename, O_CREAT|O_EXCL ....)
However, O_CREAT|O_EXCL is useless when a file name must be unique
across multiple directories.
Which was exactly the point I was making in the paragraph quoted above.
> AIX does NOT use random PID's. To the layman it may look like it, but in
> reality the PID is comprised of several fields. It is this way because
> AIX uses a dynamically extendable process table.
> The actual 32-bit PID is made up of not just the index into the table,
> but also the generation (2^8 I think from memory) of the process.
> You can see it working if you look at the process id's of processes
> created in sequence. YOu can see the dynamic extension of the process
> table if you create lots of processes. After the table is full, then it
> gets extended and suddenly the PID's of processes jump in apparent size.
> It's documented reasonably well in the online docs (Available on IBM's
> website as well if you want) if you're interested.
How does this scheme prevent a PID from being reused after a short
amount of time? If the PID fields aren't incremented monotonically,
then one needs to maintain history of past PID usage.
To unsubscribe, send mail to with content
(not subject): unsubscribe postfix-users