zombie to exist after the termination of main program..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anilchowdhury
    New Member
    • Feb 2008
    • 1

    zombie to exist after the termination of main program..

    main()
    {
    pid_t child;
    child=fork();

    if(child > 0)

    {sleep(60);
    }

    else
    {exit(0);
    }

    }

    the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
  • Arulmurugan
    New Member
    • Jan 2008
    • 90

    #2
    Originally posted by anilchowdhury
    main()
    {
    pid_t child;
    child=fork();

    if(child > 0)

    {sleep(60);
    }

    else
    {exit(0);
    }

    }

    the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
    Hello,
    You could avoid a process to get into Zombie state.but once it been to zombie you can't do anything , offcource if you know process id , it is possibe to kill.
    In kernel mode it is possible to do something.
    -Arul

    Comment

    • ashitpro
      Recognized Expert Contributor
      • Aug 2007
      • 542

      #3
      Originally posted by anilchowdhury
      main()
      {
      pid_t child;
      child=fork();

      if(child > 0)

      {sleep(60);
      }

      else
      {exit(0);
      }

      }

      the above code will create zombie process,which will be adopted by init as soon as parent process will dies.Can any one gimme a code or an alogrithm such that this zombie process should exists even after the termintaion of the main program....
      parent process won't die until all child finishes.
      consider above process is "a.out", when you run this code.
      and give the following command to view the process hierarchy.
      "ps -eLF | grep a.out"
      It will show you two "a.out" processes as running, out of which one will be defunct this is the child process. And other one is parent.
      For 60 seconds this defunct will exist.

      If you want this zombie process to exist, use non terminating loop in child code

      Comment

      Working...