diff options
author | Nuno Gonçalves <nunojpg@gmail.com> | 2016-06-14 18:55:53 -0700 |
---|---|---|
committer | Gary E. Miller <gem@rellim.com> | 2016-06-14 18:55:53 -0700 |
commit | 7d66bc921d141702dd53e93e210d88c1bca4bac6 (patch) | |
tree | bacce99f7ad361b4c70d4e8893c8d2ca3d87b4ff /gpsd.c | |
parent | 0ff6913bc7963611c6fb00091c38871d16e9e527 (diff) | |
download | gpsd-7d66bc921d141702dd53e93e210d88c1bca4bac6.tar.gz |
Don't daemonize gpsd if no good device or control socket.
This used to hang: gpsd -n /dev/ttyXXX
Now it exits with an error.
Signed-off-by: Gary E. Miller <gem@rellim.com>
Diffstat (limited to 'gpsd.c')
-rw-r--r-- | gpsd.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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; |