473,386 Members | 1,962 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to create Zombie ?

Hey guys i need help on this problem ....
Please tell me how to create zombie in linux using fork() ?
Mar 21 '08 #1
6 11323
ashitpro
542 Expert 512MB
Hey guys i need help on this problem ....
Please tell me how to create zombie in linux using fork() ?
when parent process issues a fork system call, it spawns a child process.
Idly parent should query the exit status of the child process by system calls like waitpid,wait etc.
But if parent process fails to do this or never issues such calls and just get terminate, then child process is said to be zombie(other name is orphan) i.e process having no parent. It just exists in memory holding the resources.
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.      int pid;
  4.      pid=fork();
  5.      if(pid>0)//child
  6.      {
  7.            sleep(1000);
  8.      }
  9.      else//parent
  10.      { 
  11.            exit(0);
  12.      }
  13. }
  14.  
Mar 21 '08 #2
micmast
144 100+
Couldn't the above code be shorter?

like this:

Expand|Select|Wrap|Line Numbers
  1. int main() {
  2. for(;;) {
  3. fork();
  4. }
  5. }
  6.  
Mar 21 '08 #3
Hey guys thanx for the replies :)
Next question, i want to ask is that how to solve these both zombie and orphan process problems ? Can u explain with an example ?
thanx...
Mar 22 '08 #4
when parent process issues a fork system call, it spawns a child process.
Idly parent should query the exit status of the child process by system calls like waitpid,wait etc.
But if parent process fails to do this or never issues such calls and just get terminate, then child process is said to be zombie(other name is orphan) i.e process having no parent. It just exists in memory holding the resources.
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.      int pid;
  4.      pid=fork();
  5.      if(pid>0)//child
  6.      {
  7.            sleep(1000);
  8.      }
  9.      else//parent
  10.      { 
  11.            exit(0);
  12.      }
  13. }
  14.  
I have a doubt is not zombie and orphan two different process? how do you link these both? Please explain me
Aug 22 '08 #5
ashitpro
542 Expert 512MB
I have a doubt is not zombie and orphan two different process? how do you link these both? Please explain me
Go through this link...
If you still have any doubts let us know...

http://wiki.answers.com/Q/What_is_Zo...Orphan_Process
Aug 27 '08 #6
Zombies are processes that have terminated but whose return value has not been read by the parent. waitpid() collects return values and kills zombies.

Orphans are child processes whose parents have died. Orphans are supposed to be adopted by init (which has PID=1).
Sep 7 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brian | last post by:
From one script, I'm spawnv'ing another that will launch mpg123 to play a specified mp3. Problem is that After the second script has launched mpg123, it'll turn into a zombie process. It doesn't...
0
by: Plymouth Acclaim | last post by:
Hi guys, We have a problem with Dual AMD64 Opteron/MySQL 4.0.18/Mandrake 10 for a very high volume site. We are evaluating the performance on our new server AMD64 and it seems it's slow compared...
4
by: A. Tillman | last post by:
We are having a really big problem with a zombie process/transaction that is blocking other processes. When looking at Lock/ProcessID under Current Activity I see a bunch of processes that are...
1
by: Kevin Murphy | last post by:
Using PG 7.4.5 on Mac OS X 10.3 ... I have a primary key that I can't destroy and can't create. One weird symptom is that when I use \d in psql to attempt to display the constraint, there is no...
0
by: Turtle | last post by:
I'm running devenv.exe from a batch file, with a /runexit command line switch. The devenv opens fine, runs and exits. All looks great, except that the next line in the batch file doesn't execute...
4
by: ctclibby | last post by:
Hi All Seem to be getting zombie sessions. /tmp/sess_ exist and are owned by daemon. I am guessing and these could come from brower crashes, networks gone down ... etc ... even from stuff that...
0
by: nisimura | last post by:
Hi, I noticed that when I used SocketServer.ForkingMixIn (ForkingTCPServer), there were always zombie processes around. I searched for where waitpid() is called in ForkingMixIn and found it in...
0
by: buttslapper | last post by:
Hi, Recently we discovered in our production server this kind of exception : We are wondering what causes the transaction to be zombied, and why do we get a nullreferenceexception in this...
2
by: anilchowdhury | last post by:
main() { pid_t child; child=fork(); if(child > 0) {sleep(60); }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.