- execlp("mhl", "mhl", "-form", filter, NULL);
- errstr = strerror(errno);
- write(2, "unable to exec mhl: ", 20);
- write(2, errstr, strlen(errstr));
- write(2, "\n", 1);
- _exit(-1);
+ switch (pid_show = fork()) {
+ case NOTOK:
+ adios(EX_OSERR, "fork", "unable to");
+ case OK:
+ dup2(fileno(in), STDIN_FILENO);
+ dup2(mailpipe[1], STDOUT_FILENO);
+ close(fileno(in));
+ close(fileno(out));
+ close(mailpipe[0]);
+ close(mailpipe[1]);
+ for (n=3; n<OPEN_MAX; n++) {
+ close(n);
+ }
+ execlp("show", "show", "-file", "-", NULL);
+ adios(EX_OSERR, "exec", "unable to");
+ break;
+ default:
+ dup2(mailpipe[0], STDIN_FILENO);
+ dup2(fileno(out), STDOUT_FILENO);
+ close(fileno(in));
+ close(fileno(out));
+ close(mailpipe[0]);
+ close(mailpipe[1]);
+ for (n=3; n<OPEN_MAX; n++) {
+ close(n);
+ }
+ execlp("mhl", "mhl", "-form", filter, NULL);
+ adios(EX_OSERR, "exec", "unable to");
+ break;
+ }