X-Git-Url: https://git.distorted.org.uk/~mdw/fwd/blobdiff_plain/9155ea97b695b6eb5fca1ee79f57b334f6c4ef53..aae68c41bca575de5d57e0b3b84e272a225520fd:/exec.c diff --git a/exec.c b/exec.c index b82eeea..afd7942 100644 --- a/exec.c +++ b/exec.c @@ -33,8 +33,9 @@ #ifdef HAVE_SETRLIMIT typedef struct xlimit { -#define R(r, n) struct rlimit n; -#include "rlimits.h" +#define XLIMIT_ENTRY(name, constant) struct rlimit name; + RLIMITS(XLIMIT_ENTRY) +#undef XLIMIT_ENTRY } xlimit; #endif @@ -138,8 +139,10 @@ typedef struct rlimit_ent { } rlimit_ent; static rlimit_ent rlimits[] = { -#define R(r, n) { #n, #r, r, offsetof(xlimit, n) }, -#include "rlimits.h" +#define TABLE_ENTRY(name, constant) \ + { #name, #constant, constant, offsetof(xlimit, name) }, + RLIMITS(TABLE_ENTRY) +#undef TABLE_ENTRY { 0, 0, 0, 0 } }; @@ -269,8 +272,9 @@ static int rlimit_option(xlimit *xl, scanner *sc) break; case w_soft: if (v > rl->rlim_max) - error(sc, "soft limit %l exceeds hard limit %l for %s", - v, rl->rlim_max, chosen->rname); + error(sc, "soft limit %lu exceeds hard limit %lu for %s", + (unsigned long)v, (unsigned long)rl->rlim_max, + chosen->rname); rl->rlim_cur = v; break; case w_hard: @@ -464,6 +468,7 @@ static void xept_attach(endpt *e, reffd *in, reffd *out) if (kid == 0) { xopts *xo = xe->xo; + mdup_fd md[3]; /* --- Fiddle with the file descriptors --- * * @@ -473,18 +478,14 @@ static void xept_attach(endpt *e, reffd *in, reffd *out) */ close(fd[0]); - if (dup2(in->fd, STDIN_FILENO) < 0 || - dup2(out->fd, STDOUT_FILENO) < 0 || - dup2(fd[1], STDERR_FILENO) < 0) { + md[0].cur = in->fd; md[0].want = STDIN_FILENO; + md[1].cur = out->fd; md[1].want = STDOUT_FILENO; + md[2].cur = fd[1]; md[2].want = STDERR_FILENO; + if (mdup(md, 3)) { moan("couldn't manipulate file descriptors: %s", strerror(errno)); _exit(1); } - if (in->fd > 2) - close(in->fd); - if (out->fd > 2) - close(out->fd); - fdflags(STDIN_FILENO, O_NONBLOCK, 0, FD_CLOEXEC, 0); fdflags(STDOUT_FILENO, O_NONBLOCK, 0, FD_CLOEXEC, 0); fdflags(STDERR_FILENO, O_NONBLOCK, 0, FD_CLOEXEC, 0); @@ -752,7 +753,7 @@ static int exec_option(xdata *x, scanner *sc) token(sc); if (sc->t == '=') token(sc); - conf_name(sc, '/', &d); + conf_fname(sc, &d); xo->dir = xstrdup(d.buf); dstr_destroy(&d); CONF_ACCEPT; @@ -766,7 +767,7 @@ static int exec_option(xdata *x, scanner *sc) token(sc); if (sc->t == '=') token(sc); - conf_name(sc, '/', &d); + conf_fname(sc, &d); xo->root = xstrdup(d.buf); dstr_destroy(&d); CONF_ACCEPT; @@ -1035,7 +1036,7 @@ static void xsource_attach(source *s, scanner *sc, target *t) ee->ops->close(ee); goto tidy; } - endpt_join(e, ee); + endpt_join(e, ee, xs->s.desc); /* --- Dispose of source and target --- */