+ ok1(close(outfd) == 0);
+ ok1(memcmp(buf, "test", sizeof(buf)) == 0);
+ ok1(waitpid(child, &status, 0) == child);
+ ok1(WIFEXITED(status));
+ ok1(WEXITSTATUS(status) == 0);
+
+ /* Errfd only should be fine. */
+ child = pipecmd(NULL, NULL, &errfd, argv[0], "err", NULL);
+ if (!ok1(child > 0))
+ exit(1);
+ ok1(read(errfd, buf, sizeof(buf)) == sizeof(buf));
+ ok1(close(errfd) == 0);
+ ok1(memcmp(buf, "test", sizeof(buf)) == 0);
+ ok1(waitpid(child, &status, 0) == child);
+ ok1(WIFEXITED(status));
+ ok1(WEXITSTATUS(status) == 0);
+
+ /* errfd == outfd should work with both. */
+ child = pipecmd(&errfd, NULL, &errfd, argv[0], "err", NULL);
+ if (!ok1(child > 0))
+ exit(1);
+ ok1(read(errfd, buf, sizeof(buf)) == sizeof(buf));
+ ok1(close(errfd) == 0);
+ ok1(memcmp(buf, "test", sizeof(buf)) == 0);
+ ok1(waitpid(child, &status, 0) == child);
+ ok1(WIFEXITED(status));
+ ok1(WEXITSTATUS(status) == 0);
+
+ child = pipecmd(&outfd, NULL, &outfd, argv[0], "out", NULL);
+ if (!ok1(child > 0))
+ exit(1);
+ ok1(read(outfd, buf, sizeof(buf)) == sizeof(buf));
+ ok1(close(outfd) == 0);