die() calls exit(), but actually at this point the program could be in a
state not allowing this. It's better to call _exit to stop the libc from
calling any handlers that might fail at this moment anyway.
close(fds[0]);
close(fds[1]);
execlp("sh", "sh", "-c", cmd, (char *)0);
- die("sent: execlp sh -c '%s':", cmd);
+ fprintf(stderr, "sent: execlp sh -c '%s': %s\n", cmd, strerror(errno));
+ _exit(1);
}
close(fds[1]);
return fds[0];