#endif
#include <mLib/bits.h>
+#include <mLib/mdup.h>
#include <mLib/tv.h>
#include "noise.h"
/* --- Handle the child end of the deal --- */
if (kid == 0) {
- int f;
+ mdup_fd mfd[3];
+ int f, i = 0;
/* --- Set the pipe as standard output, close standard input --- */
- close(0); close(1); close(2);
-
- if (fd[1] != 1) {
- if (dup2(fd[1], 1) < 0) _exit(127);
- close(fd[1]);
- }
-
- if ((f = open("/dev/null", O_RDONLY)) != 0 ||
- (f = open("/dev/null", O_WRONLY)) != 2)
- _exit(127);
+ if ((f = open("/dev/null", O_RDONLY)) < 0) _exit(127);
+ mfd[i].cur = f; mfd[i].want = 0; i++;
+ mfd[i].cur = fd[1]; mfd[i].want = 1; i++;
+ mfd[i].cur = f; mfd[i].want = 2; i++;
+ if (mdup(mfd, i)) _exit(127);
/* --- Play games with uids --- */