mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
Add --disable-shm / FAKETIME_DISABLE_SHM
The use of shared memory has side effects. Currently, the only way to opt out of shared memory is by compiling with -DFAKE_STATELESS. To allow disabling shared memory without recompiling, this patch introduces the --disable-shm option to `faketime`, equivalent to setting the `FAKETIME_DISABLE_SHM=1` environment variable.
This commit is contained in:
3
README
3
README
@@ -486,6 +486,9 @@ for long-running systems (servers with high uptime) and systems on which
|
||||
a lot of processes are started (e.g., servers handling many containers
|
||||
or similar virtualization mechanisms).
|
||||
|
||||
Use of shared memory can be disabled by setting the FAKETIME_DISABLE_SHM
|
||||
environment variable, or equivalently, passing --disable-shm to faketime.
|
||||
|
||||
|
||||
Intercepting time-setting calls
|
||||
-------------------------------
|
||||
|
||||
@@ -32,6 +32,9 @@ use the advanced timestamp specification format.
|
||||
\fB\--exclude-monotonic\fR
|
||||
Do not fake time when the program makes a call to clock_gettime with a CLOCK_MONOTONIC clock.
|
||||
.TP
|
||||
\fB\--disable-shm\fR
|
||||
Disable use of shared memory by libfaketime.
|
||||
.TP
|
||||
\fB\--date-prog <PATH>\fR
|
||||
Use a specific GNU-date compatible implementation of the helper used to transform "timestamp format" strings into programmatically usable dates, instead of a compile-time default guess for the generic target platform.
|
||||
|
||||
|
||||
@@ -77,6 +77,9 @@ void usage(const char *name)
|
||||
" --exclude-monotonic : Prevent monotonic clock from drifting (not the raw monotonic one)\n"
|
||||
#ifdef FAKE_PID
|
||||
" -p PID : Pretend that the program's process ID is PID\n"
|
||||
#endif
|
||||
#ifndef FAKE_STATELESS
|
||||
" --disable-shm : Disable use of shared memory by libfaketime.\n"
|
||||
#endif
|
||||
" --date-prog PROG : Use specified GNU-compatible implementation of 'date' program\n"
|
||||
"\n"
|
||||
@@ -150,6 +153,14 @@ int main (int argc, char **argv)
|
||||
curr_opt++;
|
||||
continue;
|
||||
}
|
||||
#ifndef FAKE_STATELESS
|
||||
else if (0 == strcmp(argv[curr_opt], "--disable-shm"))
|
||||
{
|
||||
setenv("FAKETIME_DISABLE_SHM", "1", true);
|
||||
curr_opt++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
else if (0 == strcmp(argv[curr_opt], "--date-prog"))
|
||||
{
|
||||
curr_opt++;
|
||||
|
||||
@@ -2790,7 +2790,10 @@ static void ftpl_really_init(void)
|
||||
#ifdef FAKE_STATELESS
|
||||
if (0) ft_shm_init();
|
||||
#else
|
||||
ft_shm_init();
|
||||
tmp_env = getenv("FAKETIME_DISABLE_SHM");
|
||||
if (!tmp_env || tmp_env[0] == '0') {
|
||||
ft_shm_init();
|
||||
}
|
||||
#endif
|
||||
#ifdef FAKE_STAT
|
||||
if (getenv("NO_FAKE_STAT")!=NULL)
|
||||
|
||||
Reference in New Issue
Block a user