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>
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);
}
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);