1 #include "stdio_impl.h"
3 FILE *popen(const char *cmd, const char *mode)
9 const char *modes = "rw", *mi = strchr(modes, *mode);
18 if (pipe(p)) return NULL;
19 f = fdopen(p[op], mode);
34 if (dup2(p[1-op], 1-op) < 0) _exit(127);
35 if (p[0] != 1-op) close(p[0]);
36 if (p[1] != 1-op) close(p[1]);
37 execl("/bin/sh", "sh", "-c", cmd, (char *)0);