Merge pull request #465 from Rob--W/add-disable-shm-option

Add --disable-shm / FAKETIME_DISABLE_SHM
This commit is contained in:
Wolfgang Hommel
2024-03-19 19:15:38 +01:00
committed by GitHub
4 changed files with 21 additions and 1 deletions

3
README
View File

@@ -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
-------------------------------

View File

@@ -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.

View File

@@ -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++;

View File

@@ -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)