> Could someone post an example of the creation of a
> temporary file where race conditions are important?

/any/ programme that does this on a multi-process system.

Between the test for existence and the creation, some other
process could have created a file of the same name. Then
the create fails because of insufficient permissions,
so the programme has to deal with failure anyway, or it
succeeds and stomps on the data belonging to the other
process.



do possible_handle <- try $ openFile "whatever" ReadMode
   case possible_handle 
     of (Right handle) -> do_things_to handle
        (Left error) -> do whatever you would have done had
                           the existence test returned false

is no more complex than a version using an existence test,
but to create a file for writing, surely we need an
openNewFile primitive? Otherwise we might open on a file
that already exists and hit the "stomp" error mentioned
above.


 Jón

-- 
Jón Fairbairn                                 [EMAIL PROTECTED]
31 Chalmers Road                                         [EMAIL PROTECTED]
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)


_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to