lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, list!

I see different behaviour of uuid:new() module on my Ubuntu Server
9.10 x86_64 and OS X Snow Leopard 10.6.2 boxes.

I fork a process, then call uuid:new() both in parent and in child. On
Ubuntu I get different results, on OS X generated UUIDs are the same.

I can't remember how I installed libuuid on OS X — I just remember
that I had some big problems with it. So, my OS X luuid installation
may be broken. Or is it the expected behaviour? Is there a workaround
then?

See details below.

I use April 2009 version of luuid.

Alexander.

The test code:

$ cat uuid-fork.lua
local posix = require 'posix'
local uuid = require 'uuid'

if assert(posix.fork()) ~= 0 then
  io.write("parent 1: ", uuid.new(), "\n")
  io.write("parent 2: ", uuid.new(), "\n")
  io.write("parent 3: ", uuid.new(), "\n")
  io.write("parent 4: ", uuid.new(), "\n")
  io.write("parent 5: ", uuid.new(), "\n")
else
  io.write("child  1: ", uuid.new(), "\n")
  io.write("child  2: ", uuid.new(), "\n")
  io.write("child  3: ", uuid.new(), "\n")
  io.write("child  4: ", uuid.new(), "\n")
  io.write("child  5: ", uuid.new(), "\n")
end

The output on OS X box:

$ lua -lluarocks.require uuid-fork.lua
parent 1: DF9C3E77-1ACB-4B15-81C8-D0E3AB0A7B4B
parent 2: 68062AA2-721D-43FF-87D6-9007F9265C2A
parent 3: 39EE9673-BE8D-4EB0-8C1D-2D22CBE94920
parent 4: B895873C-B589-4944-AE16-39D811E28E5A
parent 5: DE5A1755-096B-4656-8001-F280DBB33358
child  1: DF9C3E77-1ACB-4B15-81C8-D0E3AB0A7B4B
child  2: 68062AA2-721D-43FF-87D6-9007F9265C2A
child  3: 39EE9673-BE8D-4EB0-8C1D-2D22CBE94920
child  4: B895873C-B589-4944-AE16-39D811E28E5A
child  5: DE5A1755-096B-4656-8001-F280DBB33358

The output on Ubuntu box:

$ lua -lluarocks.require uuid-fork.lua
parent 1: 43276d7a-ec33-418d-bd99-27bb27ed4ed8
parent 2: 58553e1e-81da-41fc-8dab-50c3d9bf8dcc
parent 3: 461a9247-876a-41f7-add5-87b4572d7740
parent 4: cbe66c54-43cd-4225-b37c-a801503606c8
child  1: 15c32294-add7-4a47-82ee-89c019667cb4
parent 5: c1ec9f2f-b1ba-4851-a718-e0d39073d2c0
child  2: 3ece9152-49f1-4133-803d-5842390d63e4
child  3: fda13f6c-b7ac-407b-abac-5b913b519c70
child  4: 16450b69-33ed-4402-a6e0-869c86477213
child  5: 7d5a4920-8bf9-4c3e-9522-d09574b4aece