summaryrefslogtreecommitdiff
path: root/shmexport.c
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2017-03-24 15:23:04 -0700
committerFred Wright <fw@fwright.net>2017-03-24 18:25:14 -0700
commit3a8d8e8d8219beb1ec01f923ea5a659054941898 (patch)
tree930a45e1cd6c580ea9c10ab9154934743a229f52 /shmexport.c
parent1f209455dd2e850b164a3f7985ad845e88efef57 (diff)
downloadgpsd-3a8d8e8d8219beb1ec01f923ea5a659054941898.tar.gz
Makes 'GPSD' SHM export exclusive.
If multiple copies of gpsd share a single SHM export (e.g., during regression tests without the previous fix), then the result is just a confusing mess. Adding the "exclusive" option to shmget() fixes this by making it fail. Note that the failure becomes a failure of shm_acquire(), which is currently ignored. TESTED: Prior to making the regression test fix for unique SHM IDs, verified that parallel regression tests got the expected failures, while non-parallel tests passed.
Diffstat (limited to 'shmexport.c')
-rw-r--r--shmexport.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/shmexport.c b/shmexport.c
index 806b85c2..fc9f66e2 100644
--- a/shmexport.c
+++ b/shmexport.c
@@ -39,7 +39,7 @@ bool shm_acquire(struct gps_context_t *context)
{
long shmkey = getenv("GPSD_SHM_KEY") ? strtol(getenv("GPSD_SHM_KEY"), NULL, 0) : GPSD_SHM_KEY;
- int shmid = shmget((key_t)shmkey, sizeof(struct shmexport_t), (int)(IPC_CREAT|0666));
+ int shmid = shmget((key_t)shmkey, sizeof(struct shmexport_t), (int)(IPC_CREAT|IPC_EXCL|0666));
if (shmid == -1) {
gpsd_log(&context->errout, LOG_ERROR,
"shmget(0x%lx, %zd, 0666) for SHM export failed: %s\n",