> For the complete documentation index, see [llms.txt](https://eric-lo.gitbook.io/lab4-process/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eric-lo.gitbook.io/lab4-process/wait/zombies.md).

# Problem 2: Zombies!

The following code simulates a shell that executes `ls` in each round.

```c
/* Wait/problematic2.c */
#include <stdio.h>
#include <unistd.h>
int main(int argc,char *argv[])
{
    while(1)
    {
        printf("Press Enter to execute ls");
        while(getchar() != '\n');
        if(!fork())
        {
            execl("/bin/ls","ls",NULL);
        }
        else
        {
            sleep(1);
         }
    }
    return 0;
}
```

The program will run without *apparent* problems. However, if you look at the system process...

![](https://848802932-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Lp-5TQgFcJFf9qOBUEC%2F-Lp-5ZB50WXwtZaIRVKh%2F-Lp-63Bp0TY6Jd-UGrx8%2Fzombies.png?generation=1568738711410941\&alt=media)

Zombies appear!!

This is the consequence of the mishandling in the parent process- the parent ignores the `SIGCHLD` signal.
