Goswin von Brederlow <[EMAIL PROTECTED]> writes:

> Philippe Troin <[EMAIL PROTECTED]> writes:
> 
> > Not needed... This should be race-free:
> >
> >   char *s;
> >   while (s = (tempnam("/tmp", "foo")) {
> >     if (mknod(s, S_IFIFO|0600, 0) == 0)
> >       break;
> >     if (errno != EEXIST)
> >       /* error */
> >   }
> >   if (!s)
> >     /* error */
> 
> What happens if the 'tempnam' is a link to somehwere else? Does mknod
> fail or create the fifo where the link points too?

It fails... The mknod(2) manpage specifies:

       If pathname already exists, or is  a  symlink,  this  call
       fails with an EEXIST error.

So the above code snippet should be safe.

Phil.

Reply via email to