Categories: DebianLinuxShell

How to create a Dummy Zombie Process in C Programming Language on Debian 10

A zombie process is a type of process that has been completed, but whose entry still remains in the process table due to lack of communication between the child and parent process. The small program developed in this tutorial can be useful for learning purposes. E.g. when it comes to detecting zombie processes under Linux.

In this tutorial, I will create a dummy zombie process in Debian 10.

Creating a Dummy Zombie Process in Debian 10

Open the notepad and paste the following code.

#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main ()
{
pid_t child_pid;child_pid = fork ();
if (child_pid > 0) {
sleep (120);
}
else {
exit (0);
}
return 0;
}

Save this file as zombie.c.  The zombie process created with this code will run for 120 seconds. You can adjust the time duration (in seconds) in the sleep function.

Next, open the terminal and run the following command to compile the above code.

cc zombie.c -o zombie

After this command, an executable objective file should have been created in your current directory.

Run the zombie file:

./zombie

When you execute the following command with grep, you will get the parent ID of the zombie process.

ps axo stat,ppid,pid,comm | grep -w defunct

So this is how you create a dummy zombie process in Debian 10. I hope you have no difficulty in following this tutorial.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago