lkml.org 
[lkml]   [2004]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: clone() <-> getpid() bug in 2.6?
Date
"Paul Rolland" <rol@as2917.net> writes:

> Hello,
>
> > It does that for the unique filenames and id stamps
> > (maildir format and
>
> I though this was a job for mktemp and co.

Sure, if you want to create a unique filename on a local unshared
disk.

But suppose you want a unique filename on a partition which might be
NFS-mounted with multiple concurrent writers. Oh, and the year is
1997. Still want to use mktemp?

Bernstein decided to name each file:

<time>.<PID>.<fully-qualified-domain-name>

This approach makes three assumptions. First, that the time does not
repeat. Second, that the FQDN is unique. Third, that the time
changes (i.e., one second elapses) before a PID is reused on the local
system. Subject to these assumptions, this is a perfectly reliable,
very efficient, lock-free way to create unique file names.

Can you do better?

Sure, Bernstein's code is an unmaintainable nightmare. But his
designs and implementations are usually pretty sound. The last
release of qmail was in 1998, and we still use it where I work. Six
years with zero crashes, zero dropped messages, and zero security
holes is not a trivial track record for an MTA.

Just don't ever try to edit the sources. :-)

- Pat
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:03    [W:0.091 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site