Commit c4f7869a authored by Geoff Simmons's avatar Geoff Simmons

Print error messages from the forked process to stderr.

parent d0b4a24c
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <unistd.h> #include <unistd.h>
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <poll.h> #include <poll.h>
#include <limits.h> #include <limits.h>
...@@ -140,12 +141,11 @@ mk_pipe(int fds[2], char *name, struct vsl_log *vsl) ...@@ -140,12 +141,11 @@ mk_pipe(int fds[2], char *name, struct vsl_log *vsl)
} }
static inline int static inline int
mk_dup(int oldfd, int newfd, char *name, struct vsl_log *vsl) mk_dup(int oldfd, int newfd)
{ {
errno = 0; errno = 0;
if (dup2(oldfd, newfd) == -1) { if (dup2(oldfd, newfd) == -1) {
VSLb(vsl, SLT_Error, "vdfp_pipe: vdp %s: dup2(2) failed: %s", fprintf(stderr, "dup2(2) failed: %s", vstrerror(errno));
name, vstrerror(errno));
return (-1); return (-1);
} }
return (0); return (0);
...@@ -239,18 +239,17 @@ vdp_init(struct req *req, void **priv) ...@@ -239,18 +239,17 @@ vdp_init(struct req *req, void **priv)
closefd(&in[1]); closefd(&in[1]);
closefd(&out[0]); closefd(&out[0]);
closefd(&err[0]); closefd(&err[0]);
if (mk_dup(in[0], STDIN_FILENO, obj->name, req->vsl) != 0) if (mk_dup(err[1], STDERR_FILENO) != 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
if (mk_dup(out[1], STDOUT_FILENO, obj->name, req->vsl) != 0) if (mk_dup(in[0], STDIN_FILENO) != 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
if (mk_dup(err[1], STDERR_FILENO, obj->name, req->vsl) != 0) if (mk_dup(out[1], STDOUT_FILENO) != 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
errno = 0; errno = 0;
if (execve(obj->path, argv, environ) == -1) { if (execve(obj->path, argv, environ) == -1) {
VSLb(req->vsl, SLT_Error, "vdfp_pipe: vdp %s: cannot " fprintf(stderr, "cannot exec %s: %s", obj->path,
"exec %s: %s", obj->name, obj->path, vstrerror(errno));
vstrerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment