diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2015-02-09 17:18:45 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-02-09 17:18:45 -0500 |
commit | 5242310d708875cba0d3042917a0c68ee6d267e7 (patch) | |
tree | b45aeefa0ba9753ba53cfd6e01bb90888c7a4d00 /gpsctl.c | |
parent | e2b8a79888f3ae9468cbe4dc7a762c2d5fe2fbd9 (diff) | |
download | gpsd-5242310d708875cba0d3042917a0c68ee6d267e7.tar.gz |
Add -R option to gpsctl to remove SHM export segment, use in SConstruct.
All regression tests pass.
Diffstat (limited to 'gpsctl.c')
-rw-r--r-- | gpsctl.c | 28 |
1 files changed, 26 insertions, 2 deletions
@@ -22,6 +22,11 @@ #include "gpsd.h" #include "revision.h" +#ifdef SHM_EXPORT_ENABLE +#include <sys/ipc.h> +#include <sys/shm.h> +#endif /* SHM_EXPORT_ENABLE */ + #define HIGH_LEVEL_TIMEOUT 8 static int debuglevel; @@ -200,8 +205,8 @@ int main(int argc, char **argv) context.errout.label = "gpsctl"; -#define USAGE "usage: gpsctl [-l] [-b | -n | -r] [-D n] [-s speed] [-c rate] [-T timeout] [-V] [-t devtype] [-x control] [-e] <device>\n" - while ((option = getopt(argc, argv, "bec:fhlnrs:t:x:D:T:V")) != -1) { +#define USAGE "usage: gpsctl [-l] [-b | -n | -r] [-D n] [-s speed] [-c rate] [-T timeout] [-V] [-t devtype] [-x control] [-R] [-e] [device]\n" + while ((option = getopt(argc, argv, "bec:fhlnrs:t:x:D:RT:V")) != -1) { switch (option) { case 'b': /* switch to vendor binary mode */ to_binary = true; @@ -288,6 +293,25 @@ int main(int argc, char **argv) case 't': /* force the device type */ devtype = optarg; break; + case 'R': /* remove the SHM export segment */ +#ifdef SHM_EXPORT_ENABLE + status = shmget(GPSD_KEY, 0, 0); + if (status == -1) { + gpsd_report(&context.errout, LOG_WARN, + "GPSD SHM segment does not exist.\n"); + exit(1); + } else { + status = shmctl(status, IPC_RMID, NULL); + if (status == -1) { + gpsd_report(&context.errout, LOG_ERROR, + "shmctl failed, errno = %d (%s)\n", + errno, strerror(errno)); + exit(1); + } + } + exit(0); +#endif /* SHM_EXPORT_ENABLE */ + break; case 'T': /* set the timeout on packet recognition */ timeout = (unsigned)atoi(optarg); explicit_timeout = true; |