]> git.itanic.dy.fi Git - rrdd/commitdiff
process: run_piped_stream: Use correct direction with fdopen()
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 1 Mar 2023 16:18:29 +0000 (18:18 +0200)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 1 Mar 2023 16:18:29 +0000 (18:18 +0200)
The stdinf, stdoutf and stderrf all refer to the file streams from the
child, and their directions are opposite on parent side, where we are
reading from or writing to them. Therefore they are bit unintuitively
opposite to what one might thought just by quickly glancing over the
code.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
process.c

index 12b77aa69821810137f7eec567d66aaebd9c1527..f7477b532697fa257c79e22927629a7974c717c7 100644 (file)
--- a/process.c
+++ b/process.c
@@ -516,7 +516,7 @@ int run_piped_stream(const char *cmd, char *const argv[],
        pid = run_piped(cmd, argv, i, o, e);
 
        if (stdinf) {
-               *stdinf = fdopen(ifd, "r");
+               *stdinf = fdopen(ifd, "w");
                if (*stdinf == NULL) {
                        pr_err("Error opening file stream for fd %d: %m\n",
                               ifd);
@@ -525,7 +525,7 @@ int run_piped_stream(const char *cmd, char *const argv[],
        }
 
        if (stdoutf) {
-               *stdoutf = fdopen(ofd, "w");
+               *stdoutf = fdopen(ofd, "r");
                if (*stdoutf == NULL) {
                        pr_err("Error opening file stream for fd %d: %m\n",
                               ofd);