Skip to content

Commit

Permalink
Handle platforms that do not implement semopen() (wolfcw#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfcw committed Aug 23, 2019
1 parent 13748dd commit 5932e38
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/faketime.c
Original file line number Diff line number Diff line change
@@ -224,6 +224,7 @@ int main (int argc, char **argv)
if (SEM_FAILED == (sem = sem_open(sem_name, O_CREAT|O_EXCL, S_IWUSR|S_IRUSR, 1)))
{
perror("sem_open");
fprintf(stderr, "The faketime wrapper only works on platforms that support the sem_open()\nsystem call. However, you may LD_PRELOAD libfaketime without using this wrapper.\n");
exit(EXIT_FAILURE);
}

6 changes: 2 additions & 4 deletions src/libfaketime.c
Original file line number Diff line number Diff line change
@@ -315,10 +315,8 @@ static void ft_shm_create(void) {
snprintf(sem_name, 255, "/faketime_sem_%ld", (long)getpid());
snprintf(shm_name, 255, "/faketime_shm_%ld", (long)getpid());
if (SEM_FAILED == (semN = sem_open(sem_name, O_CREAT|O_EXCL, S_IWUSR|S_IRUSR, 1)))
{
perror("libfaketime: In ft_shm_create(), sem_open failed");
fprintf(stderr, "libfaketime: attempted sem_name was %s\n", sem_name);
exit(EXIT_FAILURE);
{ /* silently fail on platforms that do not support sem_open() */
return;
}
/* create shm */
if (-1 == (shm_fdN = shm_open(shm_name, O_CREAT|O_EXCL|O_RDWR, S_IWUSR|S_IRUSR)))

0 comments on commit 5932e38

Please sign in to comment.