summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Hommel <wolfcw@users.noreply.github.com>2021-02-25 19:29:11 +0100
committerGitHub <noreply@github.com>2021-02-25 19:29:11 +0100
commit9a38e5d775bd55be74004c883db1379da8b67e37 (patch)
treee7257c8e630e69f74d715ddea5cb85916e4d123d
parent9337bccfcb7512ebf66bcbaf0f13f878cd53a6e8 (diff)
parent7f4e5c378ae228b08ec4b10042d9de682281b3f9 (diff)
downloadlibfaketime-9a38e5d775bd55be74004c883db1379da8b67e37.tar.gz
Merge pull request #305 from dkg/fix-shm
Use real_getpid instead of getpid in ft_shm_create() under FAKE_PID
-rw-r--r--src/libfaketime.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libfaketime.c b/src/libfaketime.c
index 66003e2..b2b0155 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -354,9 +354,15 @@ static void ft_shm_create(void) {
struct ft_shared_s *ft_sharedN;
char shared_objsN[513];
sem_t *shared_semT = NULL;
+ pid_t pid;
- snprintf(sem_name, 255, "/faketime_sem_%ld", (long)getpid());
- snprintf(shm_name, 255, "/faketime_shm_%ld", (long)getpid());
+#ifdef FAKE_PID
+ pid = real_getpid();
+#else
+ pid = getpid();
+#endif
+ snprintf(sem_name, 255, "/faketime_sem_%ld", (long)pid);
+ snprintf(shm_name, 255, "/faketime_shm_%ld", (long)pid);
if (SEM_FAILED == (semN = sem_open(sem_name, O_CREAT|O_EXCL, S_IWUSR|S_IRUSR, 1)))
{ /* silently fail on platforms that do not support sem_open() */
return;