Yep, it is time to spit out some C code.
create_zombie.c - when compiled this would create a zombie process.
$ ./create_zombie Parent at pid: 19240 and ppid: 20225 Our child 19241 will be the zombie, watch below: S PID COMMAND Z 19241 [create_zombie]
Below is the C code behind this:
/* * Author: evuraan * * when the child has exited, and the parent has not * yet collected the child's death certificate, * the child process becomes a zombie * */ #includechar *cmd[300]; int main(){ int pid; pid = vfork(); if (pid == 0){ /* child */ exit(0); } else { /* parent */ printf("Parent at pid: %d and ppid: %d\n", getpid(), getppid() ); printf("Our child %d will be the zombie, watch below:\n", pid); sprintf(&cmd, "%s %d", "ps -o state,pid,command -p ", pid); sleep(1); system(cmd); } return 0; }
(Also available at : https://evuraan.info/evuraan/stuff/create_zombie.c.txt)
No comments:
Post a Comment