summaryrefslogtreecommitdiff
path: root/shmexport.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-02-09 22:51:18 -0500
committerEric S. Raymond <esr@thyrsus.com>2015-02-09 22:51:18 -0500
commitfacc08793683c63cc658d0ae549f3561411f0a08 (patch)
treef22ff00cf1dd2f7df28c325b40b0f0783ecee463 /shmexport.c
parent5b4af8cc002773058ad744f9c2f9975284b09224 (diff)
downloadgpsd-facc08793683c63cc658d0ae549f3561411f0a08.tar.gz
Implement and document GPSD_SHM_KEY environment variable.
Diffstat (limited to 'shmexport.c')
-rw-r--r--shmexport.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shmexport.c b/shmexport.c
index 1d9549d9..d4dcf01d 100644
--- a/shmexport.c
+++ b/shmexport.c
@@ -21,6 +21,7 @@ PERMISSIONS
#include <stddef.h>
#include <string.h>
#include <errno.h>
+#include <stdlib.h>
#include <sys/time.h>
#include <sys/ipc.h>
#include <sys/shm.h>
@@ -33,13 +34,13 @@ PERMISSIONS
bool shm_acquire(struct gps_context_t *context)
/* initialize the shared-memory segment to be used for export */
{
- int shmid;
+ int shmid = getenv("GPSD_SHM_KEY") ? atoi(getenv("GPSD_SHM_KEY")) : GPSD_KEY;
- shmid = shmget((key_t)GPSD_KEY, sizeof(struct gps_data_t), (int)(IPC_CREAT|0666));
+ shmid = shmget((key_t)shmid, sizeof(struct gps_data_t), (int)(IPC_CREAT|0666));
if (shmid == -1) {
gpsd_report(&context->errout, LOG_ERROR,
"shmget(%ld, %zd, 0666) failed: %s\n",
- (long int)GPSD_KEY,
+ (long int)shmid,
sizeof(struct gps_data_t),
strerror(errno));
return false;