summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorNuno Gonçalves <nunojpg@gmail.com>2016-06-14 18:55:53 -0700
committerGary E. Miller <gem@rellim.com>2016-06-14 18:55:53 -0700
commit7d66bc921d141702dd53e93e210d88c1bca4bac6 (patch)
treebacce99f7ad361b4c70d4e8893c8d2ca3d87b4ff /gpsd.c
parent0ff6913bc7963611c6fb00091c38871d16e9e527 (diff)
downloadgpsd-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.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/gpsd.c b/gpsd.c
index d98d4466..a70b31c9 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;