X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=execute.c;h=5def5ce1af5c8a553867168d9721ff3a1510852e;hb=6632c6023c5f90e15440231500d3431e869e4577;hp=bcaa4e959d580c0d3ed65a9f5615b1e2367f416d;hpb=44d8db9e5aa86165c97289f6c78a7e42bac78362;p=elogind.git diff --git a/execute.c b/execute.c index bcaa4e959..5def5ce1a 100644 --- a/execute.c +++ b/execute.c @@ -11,6 +11,7 @@ #include "strv.h" #include "macro.h" #include "util.h" +#include "log.h" static int close_fds(int except[], unsigned n_except) { DIR *d; @@ -85,7 +86,7 @@ static int shift_fds(int fds[], unsigned n_fds) { if ((nfd = fcntl(fds[i], F_DUPFD, i+3)) < 0) return -errno; - assert_se(close_nointr(fds[i])); + assert_se(close_nointr(fds[i]) == 0); fds[i] = nfd; /* Hmm, the fd we wanted isn't free? Then @@ -111,6 +112,8 @@ int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, assert(ret); assert(fds || n_fds <= 0); + log_debug("about to execute %s", command->path); + if ((pid = fork()) < 0) return -errno; @@ -190,6 +193,9 @@ int exec_spawn(const ExecCommand *command, const ExecContext *context, int *fds, _exit(r); } + + log_debug("executed %s as %llu", command->path, (unsigned long long) pid); + *ret = pid; return 0; } @@ -250,7 +256,6 @@ void exec_command_free_array(ExecCommand **c, unsigned n) { } } - void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) { assert(c); assert(f); @@ -286,7 +291,7 @@ char *exec_command_line(ExecCommand *c) { assert(c); assert(c->argv); - k = 0; + k = 1; STRV_FOREACH(a, c->argv) k += strlen(*a)+3; @@ -310,6 +315,8 @@ char *exec_command_line(ExecCommand *c) { } + *p = 0; + /* FIXME: this doesn't really handle arguments that have * spaces and ticks in them */