1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <fcntl.h> #include <unistd.h> int main(void) { int fd; fd = open("/dev/console", O_RDWR); if (fd >= 0) { dup2(fd, 0); dup2(fd, 1); dup2(fd, 2); if (fd > 2) close(fd); } execl("/bin/sh", "sh", (char *)NULL); return (1); }