Handle platforms that do not implement semopen() (#203)

This commit is contained in:
Wolfgang Hommel
2019-08-23 10:08:32 +02:00
parent 13748ddb22
commit 5932e38032
2 changed files with 3 additions and 4 deletions

View File

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

View File

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