[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gpsd-dev] gpsd doesn't terminate but crash with a SIGINT.
From: |
Gary E. Miller |
Subject: |
Re: [gpsd-dev] gpsd doesn't terminate but crash with a SIGINT. |
Date: |
Tue, 14 Jun 2016 19:01:12 -0700 |
Yo Nuno!
Patch applied. In git head now. I suspect this might solve some
unexplained error reports.
Basically it prevets gpsd daemonizing when a bad device is given on the
command line: gpsd -n /dev/ttyXXX
Here would be an intersting case to think about:
# gpsd -n /dev/ttyXX /dev/ttyS0
where /dev/ttyXX oes not exist but /dev/ttyS0 does. Right now it
silently daemonizes with just /dev/ttyS0. Maybe it should also exit?
On Mon, 13 Jun 2016 01:31:04 +0100
Nuno Gonçalves <address@hidden> wrote:
> And sorry but it had a mistake. Please check this. (diff also in
> attach).
>
> diff --git a/gpsd.c b/gpsd.c
> index d98d446..a70b31c 100644
> --- a/gpsd.c
> +++ b/gpsd.c
> @@ -1839,6 +1839,7 @@ int main(int argc, char *argv[])
> struct gps_device_t *device;
> int i, option;
> int msocks[2] = {-1, -1};
> + bool device_opened = false;
> bool go_background = true;
> volatile bool in_restart;
>
> @@ -2057,9 +2058,25 @@ int main(int argc, char *argv[])
> gpsd_log(&context.errout, LOG_ERROR,
> "initial GPS device %s open failed\n",
> argv[i]);
> + } else {
> + device_opened = true;
> }
> }
>
> + if (
> +#ifdef CONTROL_SOCKET_ENABLE
> + control_socket == NULL &&
> +#endif
> +#ifdef SYSTEMD_ENABLE
> + sd_socket_count <= 0 &&
> +#endif
> + !device_opened) {
> + gpsd_log(&context.errout, LOG_ERROR,
> + "can't run with neither control socket nor devices
> open\n");
> + exit(EXIT_FAILURE);
> + }
> +
> +
> /* drop privileges */
> if (0 == getuid()) {
> struct passwd *pw;
>
> Thanks,
> Nuno
>
> On Sun, Jun 12, 2016 at 11:18 PM, Nuno Gonçalves <address@hidden>
> wrote:
> > Any chance to give a look at this?
> >
> > I refreshed the patch:
> >
> > diff --git a/gpsd.c b/gpsd.c
> > index d98d446..1521045 100644
> > --- a/gpsd.c
> > +++ b/gpsd.c
> > @@ -1839,6 +1839,7 @@ int main(int argc, char *argv[])
> > struct gps_device_t *device;
> > int i, option;
> > int msocks[2] = {-1, -1};
> > + bool device_opened = false;
> > bool go_background = true;
> > volatile bool in_restart;
> >
> > @@ -2057,9 +2058,28 @@ int main(int argc, char *argv[])
> > gpsd_log(&context.errout, LOG_ERROR,
> > "initial GPS device %s open failed\n",
> > argv[i]);
> > + } else {
> > + device_opened = true;
> > }
> > }
> >
> > + if (
> > +#ifdef CONTROL_SOCKET_ENABLE
> > + control_socket == NULL
> > +#endif
> > +#if defined(CONTROL_SOCKET_ENABLE) && defined(SYSTEMD_ENABLE)
> > + &&
> > +#endif
> > +#ifdef SYSTEMD_ENABLE
> > + sd_socket_count <= 0
> > +#endif
> > + && !device_opened) {
> > + gpsd_log(&context.errout, LOG_ERROR,
> > + "can't run with neither control socket nor devices
> > open\n");
> > + exit(EXIT_FAILURE);
> > + }
> > +
> > +
> > /* drop privileges */
> > if (0 == getuid()) {
> > struct passwd *pw;
> >
> > Thanks,
> > Nuno
> >
> > On Thu, Apr 14, 2016 at 2:14 AM, Nuno Gonçalves <address@hidden>
> > wrote:
> >> On Thu, Apr 14, 2016 at 1:53 AM, Gary E. Miller <address@hidden>
> >> wrote:
> >>> Yo Nuno!
> >>>
> >>> You say:
> >>>
> >>>> + "can't run with no devices open\n");
> >>>
> >>> But, gpsd can run with no devices opened, if started with the -F
> >>> control-socket option. Does your patch allow for that?
> >>
> >> I believe this would:
> >>
> >> --- a/gpsd.c
> >> +++ b/gpsd.c
> >> @@ -1835,6 +1835,7 @@ int main(int argc, char *argv[])
> >> struct gps_device_t *device;
> >> int i, option;
> >> int msocks[2] = {-1, -1};
> >> + bool device_opened = false;
> >> bool go_background = true;
> >> volatile bool in_restart;
> >>
> >> @@ -2053,9 +2054,27 @@ int main(int argc, char *argv[])
> >> gpsd_log(&context.errout, LOG_ERROR,
> >> "initial GPS device %s open failed\n",
> >> argv[i]);
> >> + } else {
> >> + device_opened = true;
> >> }
> >> }
> >>
> >> + if (
> >> +#ifdef CONTROL_SOCKET_ENABLE
> >> + control_socket == NULL
> >> +#endif
> >> +#if defined(CONTROL_SOCKET_ENABLE) && defined(SYSTEMD_ENABLE)
> >> + &&
> >> +#endif
> >> +#ifdef SYSTEMD_ENABLE
> >> + sd_socket_count <= 0
> >> +#endif
> >> + && !device_opened) {
> >> + gpsd_log(&context.errout, LOG_ERROR,
> >> + "can't run with neither control socket nor
> >> devices open\n");
> >> + exit(EXIT_FAILURE);
> >> + }
> >> +
> >> /* drop privileges */
> >> if (0 == getuid()) {
> >> struct passwd *pw;
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
address@hidden Tel:+1 541 382 8588
pgpLTwtgNJrJY.pgp
Description: OpenPGP digital signature