diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2005-01-11 06:02:24 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2005-01-11 06:02:24 +0000 |
commit | 3bb58ca7d32055e8c4b5f6eab09f7df2223c6e8b (patch) | |
tree | 931b2bd1341a5c8ef1e2d0e9d50abed424f04699 | |
parent | 1a4dee48a88af1357a3122aa22e6debac0d85c30 (diff) | |
download | gpsd-3bb58ca7d32055e8c4b5f6eab09f7df2223c6e8b.tar.gz |
Added -P option.
-rw-r--r-- | gpsd.c | 23 | ||||
-rw-r--r-- | gpsd.spec.in | 5 | ||||
-rw-r--r-- | gpsd.xml | 9 |
3 files changed, 32 insertions, 5 deletions
@@ -35,6 +35,7 @@ struct gps_session_t *session; static char *device_name = DEFAULT_DEVICE_NAME; +static char *pid_file = NULL; static fd_set all_fds, nmea_fds, watcher_fds; static int debuglevel, nfds, in_background = 0; @@ -53,6 +54,18 @@ static void onsig(int sig) exit(10 + sig); } +static void store_pid(pid_t pid) +{ + FILE *fp; + + if ((fp = fopen(pid_file, "w")) != NULL) { + fprintf(fp, "%u\n", pid); + (void) fclose(fp); + } else { + gpsd_report(1, "Cannot create PID file: %s.\n", pid_file); + } +} + static int daemonize(void) { int fd; @@ -64,7 +77,9 @@ static int daemonize(void) case 0: /* child side */ break; default: /* parent side */ - _exit(pid); + if (pid_file) + store_pid(pid); + exit(0); } if (setsid() == -1) @@ -114,6 +129,7 @@ static void usage(void) #endif /* TRIPMATE_ENABLE */ " -s baud_rate = set baud rate on gps device \n\ -d host[:port] = set DGPS server \n\ + -P pidfile = set file to record process ID \n\ -D integer (default 0) = set debug level \n\ -h = help message \n", DEFAULT_DEVICE_NAME, DEFAULT_GPSD_PORT); @@ -402,7 +418,7 @@ int main(int argc, char *argv[]) extern char *optarg; debuglevel = 1; - while ((option = getopt(argc, argv, "D:S:d:hnp:s:v" + while ((option = getopt(argc, argv, "D:S:d:hnp:P:s:v" #if TRIPMATE_ENABLE || defined(ZODIAC_ENABLE) "i:" #endif /* TRIPMATE_ENABLE || defined(ZODIAC_ENABLE) */ @@ -455,6 +471,9 @@ int main(int argc, char *argv[]) case 'p': device_name = optarg; break; + case 'P': + pid_file = optarg; + break; case 's': gpsd_speed = atoi(optarg); break; diff --git a/gpsd.spec.in b/gpsd.spec.in index d9193f0b..cb4d8991 100644 --- a/gpsd.spec.in +++ b/gpsd.spec.in @@ -121,10 +121,11 @@ if [ -d /etc/udev/rules.d/ ]; then rm /etc/udev/rules.d/80-gpsd.rules; fi %changelog * Sat Jan 1 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 2.7-1 - More compiler-warning cleanups. Added --speedunits option to xgpsspeed, - --spedunits and --altunits options to xgps. Improved GPGSV parsing so + --speedunits and --altunits options to xgps. Improved GPGSV parsing so it copes gracefully if we start in the middle of a sequence. Merged Petter Reinholdtsen's fix for GPGSA lists with holes. In xgps, - satellites used in the last fix are now dotted in the middle. + satellites used in the last fix are now dotted in the middle. New + -P option to create pidfile. * Sat Jan 01 2005 Eric S. Raymond <esr@snark.thyrsus.com> - 2.6-1 - Petter Reinholdtsen's fix for gps.py buffering. Fix syntax errors @@ -27,6 +27,7 @@ and speedometer</refpurpose> <arg choice='opt'>-i <replaceable>initial-position</replaceable></arg> <arg choice='opt'>-n </arg> <arg choice='opt'>-h </arg> + <arg choice='opt'>-P <replaceable>pidfile</replaceable></arg> <arg choice='opt'>-D <replaceable>debuglevel</replaceable></arg> <arg choice='opt'>-v </arg> </cmdsynopsis> @@ -134,6 +135,12 @@ monitoring of the GPS data stream.</para> <listitem><para>Display help message and terminate.</para></listitem> </varlistentry> <varlistentry> +<term>-P</term> +<listitem> +<para>Specify the name and path to record the daemon's process ID.</para> +</listitem> +</varlistentry> +<varlistentry> <term>-D</term> <listitem> <para>Set debug level. At debug levels 2 and above, @@ -384,7 +391,7 @@ NMEA</ulink>.</para> This manual page by Eric S. Raymond <email>esr@thyrsus.com</email>. There is a project page, with <application>xgps</application> screenshots, <ulink -url="http://www.berlios.de/gpsd/">here</ulink>.</para> +url="http://gpsd.berlios.de/">here</ulink>.</para> </refsect1> |