[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: how to make a string outlive the invocation of a C function?
- From: Asko Kauppi <askok@...>
- Date: Tue, 17 Apr 2007 12:31:57 +0300
Jesús Ruiz de Infante kirjoitti 17.4.2007 kello 12:04:
Gé Weijers wrote:
Every process should get a copy of your global variables, not
share them with other processes. Global variables are shared
between (Posix) threads that are part of the same process, not
between processes (the library loader usually uses copy-on-write
pages to implement this). I would still prefer a reentrant
solution though, so storing it in the module environment is the
right thing to do.
You are right. Static variables contained in DLLs are not shared by
the processes linked against them. At least not on Linux. Is this
This is standardized. Processes are certainly different, but use of
your module in multithreading scenarios s.a. Lanes would be affected
- there each separate Lua state is run as an OS thread, and modules
may be initialized multiple times.
You can at least detect multiple initialization by checking, if a
global already has a value. That would give an error instead of just
weird behaviour later at runtime.