I am trying to create a zombie process in C do the following:
1 - creating child process
2 - let the parent wait/sleep for 60s
3 - child process ends after creating it immediately.
And i want to show details in console about the process and its usage of CPU for example.
i wrote the following code but i see nothing running in console with this command ps -l
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
int main()
{
int pid = fork();
// Parent process
if (pid > 0)
sleep(60);
// Child process
else {
exit(0);
}
return 0;
}