What is Zombie process and How to create zombie process in Linux ?

Zombie process is the process which died immediately and whose parent didn’t cared to handled the status of child death. When a child process exits, it is not immediately cleared off the process table. Instead, a signal is sent to its parent process, which needs to acknowledge it’s child’s death, and only then the child process is completely removed from the system. If a parent is not written by taking care of handling acknowledgement from child, the child becomes zombie.

Such process’s continues to run in


state till the parent is exited completely.

 vim create_zombie.c 
int main(int argc, char **argv) {
        pid_t child_pid;
        int child_status;

        child_pid = fork();
        switch (child_pid) {
                case -1:
                        printf("error: we can use perror\n");
                case 0:
                        printf("child is getting dead immediately\n");
                        printf("parent process continuing to execute, but not cared of child is dead or alive\n");
                        sleep (180);
        return 0;

you can run below program as,

        gcc -o our_zombie_child create_zombie.c

This program makes parent goes sleep for 180 sec, meantime child has already died, but parent process doesn’t handles the child’s death since it was already in sleep ( normally this child death report needs to handled using signal in parent process )

so now, you can open another terminal and type

        $ ps -ax | grep defunct
          5208 pts/1    Z+     0:00 [our_zombie_chil] defunct

where “ps” command showed, child process which we created became zombie. [ as indicated by defunct ]

Android Android Commands Android Java Applications Application Libraries Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Content Management System - CMS Core Kernel C Programs Development Environment Setup Errors & Failures File Systems git Go Language Programs Hardware Platforms Home HTML JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply