summaryrefslogtreecommitdiff
path: root/gpsdctl.c
diff options
context:
space:
mode:
authorMichael Tatarinov <kukabu@gmail.com>2013-10-21 11:52:19 +0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-21 06:17:00 -0400
commit88e9113b7ed9745d71c3d91f17c00b878960cde9 (patch)
treef7e4dc89a9e5460014fde944dcf1ef63e5f42e5b /gpsdctl.c
parentd5bbb5285781c2fe36d6c219d3e738229d36ead2 (diff)
downloadgpsd-88e9113b7ed9745d71c3d91f17c00b878960cde9.tar.gz
In gpsdctl: handle the unknown action.
Diffstat (limited to 'gpsdctl.c')
-rw-r--r--gpsdctl.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gpsdctl.c b/gpsdctl.c
index a1ac0844..4a9e4017 100644
--- a/gpsdctl.c
+++ b/gpsdctl.c
@@ -31,6 +31,7 @@ static int gpsd_control(char *action, char *argument)
{
int connect = -1;
char buf[512];
+ int status;
(void)syslog(LOG_ERR, "gpsd_control(action=%s, arg=%s)", action, argument);
if (access(control_socket, F_OK) == 0 &&
@@ -73,17 +74,20 @@ static int gpsd_control(char *action, char *argument)
if (stat(argument, &sb) != 1)
(void)chmod(argument, sb.st_mode | S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
(void)snprintf(buf, sizeof(buf), "+%s\r\n", argument);
- ignore_return(write(connect, buf, strlen(buf)));
+ status = write(connect, buf, strlen(buf));
ignore_return(read(connect, buf, 12));
} else if (strcmp(action, "remove") == 0) {
(void)snprintf(buf, sizeof(buf), "-%s\r\n", argument);
- ignore_return(write(connect, buf, strlen(buf)));
+ status = write(connect, buf, strlen(buf));
ignore_return(read(connect, buf, 12));
+ } else {
+ (void)syslog(LOG_ERR, "unknown action \"%s\"", action);
+ status = -1;
}
/*@ +sefparams @*/
(void)close(connect);
//syslog(LOG_DEBUG, "gpsd_control ends");
- return 0;
+ return status;
}
int main(int argc, char *argv[])