aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-25 22:11:48 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-25 22:11:48 +0100
commit8ff7ea824ce12a40901dd9d81e7bf0dd46c4ee54 (patch)
tree346295f74b92e55bca0e22cfa1cad4e6cfa0eadf
parentsatr run select jobs + satrm can remove multiple jobs (diff)
downloadsat-8ff7ea824ce12a40901dd9d81e7bf0dd46c4ee54.tar.gz
sat-8ff7ea824ce12a40901dd9d81e7bf0dd46c4ee54.tar.bz2
sat-8ff7ea824ce12a40901dd9d81e7bf0dd46c4ee54.tar.xz
send job
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--src/sat.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/sat.c b/src/sat.c
index 6074c10..8cb87cf 100644
--- a/src/sat.c
+++ b/src/sat.c
@@ -69,8 +69,8 @@ main(int argc, char *argv[], char *envp[])
{
struct timespec ts;
clockid_t clk;
- char *message;
- size_t message_size;
+ char *msg = NULL;
+ size_t n;
if ((argc < 3) || (argv[1][0] == '-')) {
usage();
@@ -105,16 +105,25 @@ main(int argc, char *argv[], char *envp[])
argv += 2;
/* Construct message to send to the daemon. */
- message_size = measure_array(argv) + measure_array(envp);
- message = malloc(message_size);
- if (!message)
+ n = measure_array(argv) + measure_array(envp);
+ if (!(msg = malloc(n + sizeof(clk) + sizeof(ts))))
goto fail;
- store_array(store_array(message, argv), envp);
+ store_array(store_array(msg, argv), envp);
+ memcpy(msg + n, clk, sizeof(clk));
+ memcpy(msg + n + sizeof(clk), ts, sizeof(ts));
- /* TODO start atd (if not started) and queue the job */
+ /* Send job to daemon, start daemon if necessary. */
+ if (send_command(SAT_QUEUE, n, msg)) {
+ if (errno)
+ goto fail;
+ free(msg);
+ return 3;
+ }
+ return 0;
fail:
perror(argv0);
+ free(msg);
return 1;
}