You cannot create a zombie process. When you fork a process and this forked process (child) ends, it sends a return code. If parent process is not waiting for this return code, child process becomes a zombie (child process, which dies and parent does not know).
In C language, it would be a wait() function in parent process which reads the return value.
Common workaround for this (if you have no intention in parent process to wait for a return code from child) is to double fork.
It means, your main process A will create new process B, which will start process C. Process B ends immediately, process A can receive its return code right after starting it. Process C will do whatever is needed (printing labels in your case) and when it ends, it will sent a return code. Its parent process B is already dead, so system will take care of it (process with pid 1 in the past, not sure how that works now). And it will not become a zombie.
Edit:
Here is an example I found at https://stackoverflow.com/questions/10932592/why-fork-twice
The first if sequence is process A after a fork, it will just wait for its child process B to finish.
int main()
{
pid_t p1 = fork();
if (p1 != 0)
{
printf("p1 process id is %d", getpid());
wait();
system("ps");
}
else
{
pid_t p2 = fork();
int pid = getpid();
if (p2 != 0)
{
printf("p2 process id is %d", pid);
}
else
{
printf("p3 process id is %d", pid);
}
exit(0);
}
}
wait()
when appropriate; that and some incredibly ugly hacks that aren't worth the effort and ugliness just to clear an entry from the process table that doesn't actually hold any resources. – David Foerster Dec 08 '16 at 15:16