Tag Info

New answers tagged


You're leaving a zombie, trivially, because you didn't wait on your child process. Your shell is immediately exiting because you've set up its STDIN in a nonsensical way. pipe returns a one-way communications channel. You write to pipefd[1] and read it back from pipefd[0]. You did a buch of dup2 calls which lead the shell to attempt to read (STDIN) from the ...


You need to catch the SIGCHLD signal, and "reap" the zombie process with a wait() system call. Nearly minimal addition of code to your program to add a signal handler function, and set it as the SIGCHLD handler looks like this: #include <cstdio> #include <fcntl.h> #include <cstring> #include <stdlib.h> #include <cerrno> ...

Top 50 recent answers are included