Getting a name for a mkfifo

Rafał Rzepecki divided.mind at gmail.com
Sat Aug 6 18:45:40 CEST 2005


On Saturday, 6 of August 2005 17:15, David Faure wrote:
> On Saturday 06 August 2005 16:21, Tomas Mecir wrote:
> > On 8/6/05, Piotr Szymański <niedakh at gmail.com> wrote:
> > > Hi,
> > > What class in KDE do I need to get a decent not taken name for a
> > > mkfifo, i'd use KTempFile, but it creates a file there right? Any
> > > ideas?
> >
> > man 3 tmpnam
> > man 3 tempnam
>
> Both say:
> BUGS
>        Never use this function.
>
> so don't. Use the name provided by a KTempFile. It still leaves a small
> race condition though, since you have to let it delete the file before you
> can create the fifo, but well, we do that already in KDE (e.g.
> KParts::ReadWritePart::prepareSaving).

I think that man 3 tmpnam says never to use it because of the inherent danger 
posed by generating a filename and only then creating the file in an 
non-atomic operation, possibly doing something in-between. Since you will be 
doing effectively the same thing with creating a tempfile and deleting it and 
placing a fifo, I think it's better to just go ahead and use the tmpnam and 
_immediately_ create the fifo (taking proper precautions of possible error 
conditions).
-- 
Rafał Rzepecki
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-soc/attachments/20050806/3d8ffcbd/attachment.pgp


More information about the Kde-soc mailing list