[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: luuid vs. forks
- From: Florian Weimer <fw@...>
- Date: Mon, 08 Feb 2010 22:35:17 +0100
* Alexander Gladysh:
>>> This looks wrong to me. Also it (indirectly) breaks my tests. So I want to
>>> ask — is this normal, or my setup is broken?
>> Your setup is broken, or more likely, the underlying random number
>> generator. fork() makes creating a good one really tricky on UNIX.
>> RAND_bytes() from OpenSSL allegedly gets this right, or you can open
>> /dev/urandom directly---but you have to make sure you've disabled
>> buffered I/O in that case.
> I'd like to avoid writing my own libuuid for OS X though...
Ah, I see. Obviously, that library isn't fork-safe. I think on Mac
OS X, the focus is on threading and not so much on forking, so you're
better off switching from a fork() to a fork()/execve() combination.
Chances are that other libraries you might use don't survive forking,
fork() is unsafe, really.