From 3a8d8e8d8219beb1ec01f923ea5a659054941898 Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Fri, 24 Mar 2017 15:23:04 -0700 Subject: 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. --- shmexport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shmexport.c') 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", -- cgit v1.2.1