aboutsummaryrefslogtreecommitdiffstats
path: root/src/satd-run.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/satd-run.c')
-rw-r--r--src/satd-run.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/satd-run.c b/src/satd-run.c
index 7cccb57..36b66e2 100644
--- a/src/satd-run.c
+++ b/src/satd-run.c
@@ -39,6 +39,8 @@ main(int argc, char *argv[])
size_t n = 0;
char *message = NULL;
char **msg_argv = NULL;
+ char **arg;
+ int rc = 0;
/* Receive and validate message. */
t (readall(SOCK_FILENO, &message, &n) || (n && message[n - 1]));
@@ -48,7 +50,27 @@ main(int argc, char *argv[])
t (!msg_argv);
}
- return 0;
+ /* Perform action. */
+ if (msg_argv) {
+ for (arg = msg_argv; *arg; arg++)
+ t (remove_job(*arg, 1) && errno);
+ } else {
+ for (;;)
+ if (remove_job(NULL, 1))
+ t (errno);
+ }
+
+done:
+ /* Cleanup. */
+ shutdown(SOCK_FILENO, SHUT_WR);
+ close(SOCK_FILENO);
+ free(msg_argv);
+ free(message);
+ return rc;
fail:
+ if (send_string(SOCK_FILENO, STDERR_FILENO, argv[0], ": ", strerror(errno), "\n", NULL))
+ perror(argv[0]);
+ rc = 1;
+ goto done;
}