Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #24 from mer-packages/initialprocess
[mkcal] Use directory as semaphore ftok id.  Contributes to MER#1246
  • Loading branch information
Chris Adams committed Aug 17, 2015
2 parents 4439eae + 31fd556 commit 36b45b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/semaphore_p.cpp
Expand Up @@ -33,6 +33,7 @@

#include <errno.h>
#include <unistd.h>
#include <libgen.h>

#include <sys/sem.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -61,7 +62,10 @@ int semaphoreInit(const char *id, size_t count, const int *initialValues)
int rv = -1;

// the specific value of proj_id is unimportant except that it must be non-zero, so 5?
key_t key = ::ftok(id, 5);
char *filepath = ::strdup(id);
char *dirpath = ::dirname(filepath);
key_t key = ::ftok(dirpath, 5);
::free(filepath);

rv = ::semget(key, count, 0);
if (rv == -1) {
Expand Down

0 comments on commit 36b45b0

Please sign in to comment.