diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-09-01 20:00:50 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-09-01 22:16:03 +0300 |
commit | 9c10801c606eceda5b37d10f441a5b7d4cfb444a (patch) | |
tree | 968a171e15c30dddba8471a9f0d528443d04b224 /src | |
parent | 5fea0129bb54feb5bfa0deb0ce8e8403b1328079 (diff) | |
download | direvent-9c10801c606eceda5b37d10f441a5b7d4cfb444a.tar.gz direvent-9c10801c606eceda5b37d10f441a5b7d4cfb444a.tar.bz2 |
Improve and document self-test mode
* src/direvent.c (self_test): Run the program as /bin/sh -c program.
* doc/direvent.texi: Document self-test mode and missing options.
* doc/direvent.8: Document self-test.
* doc/direvent.conf.5: Likewise.
* src/cmdline.opt: Fix option declarations.
Diffstat (limited to 'src')
-rw-r--r-- | src/cmdline.opt | 4 | ||||
-rw-r--r-- | src/direvent.c | 23 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/cmdline.opt b/src/cmdline.opt index 5d6eafe..b7e1dd7 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -46,13 +46,13 @@ BEGIN opt_pidfile = optarg; END -OPTION(lint,t,,, +OPTION(lint,t,, [<check configuration file and exit>]) BEGIN lint_only = 1; END -OPTION(user,u,USER,, +OPTION(user,u,USER, [<run as this user>]) BEGIN opt_user = optarg; diff --git a/src/direvent.c b/src/direvent.c index 5840f2e..aa0e2f3 100644 --- a/src/direvent.c +++ b/src/direvent.c @@ -404,22 +404,13 @@ sigmain(int sig) stop = 1; } } -extern char **environ; void self_test() { pid_t pid; - struct wordsplit ws; - - ws.ws_env = (const char **)environ; - if (wordsplit(self_test_prog, &ws, - WRDSF_NOCMD | WRDSF_QUOTE | WRDSF_SQUEEZE_DELIMS | - WRDSF_CESCAPES | WRDSF_ENV)) { - diag(LOG_CRIT, "wordsplit: %s", wordsplit_strerror (&ws)); - exit(2); - } - + char *args[4]; + pid = fork(); if (pid == (pid_t)-1) { diag(LOG_CRIT, @@ -432,10 +423,14 @@ self_test() self_test_pid = pid; return; } - - execv(ws.ws_wordv[0], ws.ws_wordv); - diag(LOG_ERR, "execv: %s: %s", ws.ws_wordv[0], strerror(errno)); + args[0] = "/bin/sh"; + args[1] = "-c"; + args[2] = self_test_prog; + args[3] = NULL; + execv(args[0], args); + + diag(LOG_ERR, "execv: %s: %s", self_test_prog, strerror(errno)); _exit(127); } |